| SidDatabase.h | | SidDatabase.h | |
|
| /************************************************************************** | | /* | |
| * | | * This file is part of libsidplayfp, a SID player engine. | |
| SidDatabase.h - songlength database support | | * | |
| ------------------- | | * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> | |
| begin : Sun Mar 11 2001 | | * Copyright 2007-2010 Antti Lankila | |
| copyright : (C) 2001 by Simon White | | * Copyright 2000-2001 Simon White | |
| email : s_a_white@email.com | | * | |
| ************************************************************************** | | * This program is free software; you can redistribute it and/or modify | |
| */ | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| /************************************************************************** | | * (at your option) any later version. | |
| * | | * | |
| * | | * This program is distributed in the hope that it will be useful, | |
| * | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * This program is free software; you can redistribute it and/or modify | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * | | * GNU General Public License for more details. | |
| * it under the terms of the GNU General Public License as published by | | * | |
| * | | * You should have received a copy of the GNU General Public License | |
| * the Free Software Foundation; either version 2 of the License, or | | * along with this program; if not, write to the Free Software | |
| * | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 | |
| * (at your option) any later version. | | 1, USA. | |
| * | | */ | |
| * | | | |
| * | | | |
| ************************************************************************** | | | |
| */ | | | |
| | | | |
|
| #ifndef _siddatabase_h_ | | #ifndef SIDDATABASE_H | |
| #define _siddatabase_h_ | | #define SIDDATABASE_H | |
| | | | |
|
| #include "sidplayfp/sidconfig.h" | | #include <stdint.h> | |
| #include "sidplayfp/sidtypes.h" | | | |
| | | | |
|
| class SidTuneMod; | | #include "sidplayfp/siddefs.h" | |
| | | | |
| | | class SidTune; | |
| class iniParser; | | class iniParser; | |
| | | | |
| /** | | /** | |
| * SidDatabase | | * SidDatabase | |
| * An utility class to deal with the songlength DataBase. | | * An utility class to deal with the songlength DataBase. | |
| */ | | */ | |
| class SID_EXTERN SidDatabase | | class SID_EXTERN SidDatabase | |
| { | | { | |
| private: | | private: | |
|
| static const char *ERR_DATABASE_CORRUPT; | | class parseError {}; | |
| static const char *ERR_NO_DATABASE_LOADED; | | | |
| static const char *ERR_NO_SELECTED_SONG; | | static const char *parseTime(const char *str, long &result); | |
| static const char *ERR_MEM_ALLOC; | | | |
| static const char *ERR_UNABLE_TO_LOAD_DATABASE; | | | |
| | | | |
|
| | | private: | |
| iniParser *m_parser; | | iniParser *m_parser; | |
| const char *errorString; | | const char *errorString; | |
| | | | |
|
| class parseError {}; | | | |
| | | | |
| static const char* parseTime(const char* str, long &result); | | | |
| | | | |
| public: | | public: | |
|
| SidDatabase (); | | SidDatabase(); | |
| ~SidDatabase (); | | ~SidDatabase(); | |
| | | | |
| /** | | /** | |
| * Open the songlength DataBase. | | * Open the songlength DataBase. | |
|
| | | * | |
| * @param filename songlengthDB file name with full path. | | * @param filename songlengthDB file name with full path. | |
|
| * @return -1 in case of errors, 0 otherwise. | | * @return false in case of errors, true otherwise. | |
| */ | | */ | |
|
| int open (const char *filename); | | bool open(const char *filename); | |
| | | | |
| /** | | /** | |
| * Close the songlength DataBase. | | * Close the songlength DataBase. | |
| */ | | */ | |
|
| void close (); | | void close(); | |
| | | | |
| /** | | /** | |
| * Get the length of the current subtune. | | * Get the length of the current subtune. | |
|
| | | * | |
| * @param tune | | * @param tune | |
| * @return tune length in seconds, -1 in case of errors. | | * @return tune length in seconds, -1 in case of errors. | |
| */ | | */ | |
|
| int_least32_t length (SidTuneMod &tune); | | int_least32_t length(SidTune &tune); | |
| | | | |
| /** | | /** | |
| * Get the length of the selected subtune. | | * Get the length of the selected subtune. | |
|
| | | * | |
| * @param md5 the md5 hash of the tune. | | * @param md5 the md5 hash of the tune. | |
| * @param song the subtune. | | * @param song the subtune. | |
| * @return tune length in seconds, -1 in case of errors. | | * @return tune length in seconds, -1 in case of errors. | |
| */ | | */ | |
|
| int_least32_t length (const char *md5, uint_least16_t song); | | int_least32_t length(const char *md5, unsigned int song); | |
| | | | |
| /// Get descriptive error message. | | /// Get descriptive error message. | |
|
| const char * error (void) { return errorString; } | | const char *error() const { return errorString; } | |
| }; | | }; | |
| | | | |
|
| #endif // _siddatabase_h_ | | #endif // SIDDATABASE_H | |
| | | | |
End of changes. 18 change blocks. |
| 48 lines changed or deleted | | 45 lines changed or added | |
|
| SidTune.h | | SidTune.h | |
| /* | | /* | |
|
| * /home/ms/files/source/libsidtune/RCS/SidTune.h,v | | * This file is part of libsidplayfp, a SID player engine. | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> | |
| * it under the terms of the GNU General Public License as published by | | * Copyright 2007-2010 Antti Lankila | |
| * the Free Software Foundation; either version 2 of the License, or | | * Copyright 2000 Simon White | |
| * (at your option) any later version. | | | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This program is free software; you can redistribute it and/or modify | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * it under the terms of the GNU General Public License as published by | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * the Free Software Foundation; either version 2 of the License, or | |
| * GNU General Public License for more details. | | * (at your option) any later version. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * This program is distributed in the hope that it will be useful, | |
| * along with this program; if not, write to the Free Software | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| SA | | * GNU General Public License for more details. | |
| | | * | |
| | | * You should have received a copy of the GNU General Public License | |
| | | * along with this program; if not, write to the Free Software | |
| | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 | |
| | | 1, USA. | |
| */ | | */ | |
| | | | |
| #ifndef SIDTUNE_H | | #ifndef SIDTUNE_H | |
| #define SIDTUNE_H | | #define SIDTUNE_H | |
| | | | |
|
| #include "sidtypes.h" | | #include <stdint.h> | |
| #include "Buffer.h" | | | |
| #include "SmartPtr.h" | | | |
| | | | |
| #include <fstream> | | #include <fstream> | |
|
| | | #include <memory> | |
| | | | |
|
| /// Also PSID file format limit. | | #include "sidplayfp/siddefs.h" | |
| const uint_least16_t SIDTUNE_MAX_SONGS = 256; | | | |
| | | | |
| const uint_least16_t SIDTUNE_MAX_CREDIT_STRINGS = 10; | | | |
| | | | |
| /// 80 characters plus terminating zero. | | | |
| const uint_least16_t SIDTUNE_MAX_CREDIT_STRLEN = 80+1; | | | |
| | | | |
| const uint_least32_t SIDTUNE_MAX_MEMORY = 65536; | | | |
| | | | |
| /// C64KB+LOAD+PSID | | | |
| const uint_least32_t SIDTUNE_MAX_FILELEN = 65536+2+0x7C; | | | |
| | | | |
|
| /// Vertical-Blanking-Interrupt | | class SidTuneInfo; | |
| const int SIDTUNE_SPEED_VBI = 0; | | class SidTuneInfoImpl; | |
| | | class SidTuneBase; | |
| /// CIA 1 Timer A | | class sidmemory; | |
| const int SIDTUNE_SPEED_CIA_1A = 60; | | | |
| | | | |
| const int SIDTUNE_CLOCK_UNKNOWN = 0x00; | | | |
| const int SIDTUNE_CLOCK_PAL = 0x01; // These are also used in the | | | |
| const int SIDTUNE_CLOCK_NTSC = 0x02; // emulator engine! | | | |
| const int SIDTUNE_CLOCK_ANY = (SIDTUNE_CLOCK_PAL | SIDTUNE_CLOCK_NTSC); | | | |
| | | | |
| const int SIDTUNE_SIDMODEL_UNKNOWN = 0x00; | | | |
| const int SIDTUNE_SIDMODEL_6581 = 0x01; // These are also used in the | | | |
| const int SIDTUNE_SIDMODEL_8580 = 0x02; // emulator engine! | | | |
| const int SIDTUNE_SIDMODEL_ANY = (SIDTUNE_SIDMODEL_6581 | SIDTUNE_SIDMO | | | |
| DEL_8580); | | | |
| | | | |
| const int SIDTUNE_COMPATIBILITY_C64 = 0x00; ///< File is C64 compatible | | | |
| const int SIDTUNE_COMPATIBILITY_PSID = 0x01; ///< File is PSID specific | | | |
| const int SIDTUNE_COMPATIBILITY_R64 = 0x02; ///< File is Real C64 only | | | |
| const int SIDTUNE_COMPATIBILITY_BASIC = 0x03; ///< File requires C64 Basic | | | |
| | | | |
| template class SID_EXTERN Buffer_sidtt<const uint_least8_t>; | | | |
| | | | |
| /** | | /** | |
|
| * An instance of this structure is used to transport values to | | * SidTune | |
| * and from SidTune objects. | | | |
| * | | | |
| * You must read (i.e. activate) sub-song specific information | | | |
| * via: | | | |
| * const SidTuneInfo& tuneInfo = SidTune[songNumber]; | | | |
| * const SidTuneInfo& tuneInfo = SidTune.getInfo(); | | | |
| * void SidTune.getInfo(tuneInfo&); | | | |
| * | | | |
| * Consider the following fields as read-only, because the SidTune class | | | |
| * does not provide an implementation of: bool setInfo(const SidTuneInfo&). | | | |
| * Currently, the only way to get the class to accept values which | | | |
| * are written to these fields is by creating a derived class. | | | |
| */ | | */ | |
|
| struct SidTuneInfo | | class SID_EXTERN SidTune | |
| { | | { | |
|
| /// the name of the identified file format | | public: | |
| const char* formatString; | | static const int MD5_LENGTH = 32; | |
| | | | |
| /// error/status message of last operation | | | |
| const char* statusString; | | | |
| | | | |
| /// describing the speed a song is running at | | | |
| const char* speedString; | | | |
| | | | |
| uint_least16_t loadAddr; | | | |
| uint_least16_t initAddr; | | | |
| uint_least16_t playAddr; | | | |
| | | | |
| /// number of songs in the tune | | | |
| uint_least16_t songs; | | | |
| | | | |
| /// the default starting song | | | |
| uint_least16_t startSong; | | | |
| | | | |
| /** | | | |
| * @name Base addresses | | | |
| * The SID chip base address(es) used by the sidtune. | | | |
| */ | | | |
| //@{ | | | |
| uint_least16_t sidChipBase1; ///< 0xD400 (normal, 1st SID) | | | |
| uint_least16_t sidChipBase2; ///< 0xD?00 (2nd SID) or 0 (no 2nd SID) | | | |
| //@} | | | |
| | | | |
| // Available after song initialization. | | | |
| | | | |
| /// the song that has been initialized | | | |
| uint_least16_t currentSong; | | | |
| | | | |
|
| /** | | private: | |
| * song speed: vertical blank interrupt (50Hz PAL, 60Hz NTSC) | | /// Filename extensions to append for various file types. | |
| * or CIA 1 timer interrupt (default 60Hz) | | static const char** fileNameExtensions; | |
| */ | | | |
| uint_least8_t songSpeed; | | | |
| | | | |
| /// specifies the video standard (clock) | | | |
| uint_least8_t clockSpeed; | | | |
| | | | |
| /// First available page for relocation | | | |
| uint_least8_t relocStartPage; | | | |
| | | | |
| /// Number of pages available for relocation | | | |
| uint_least8_t relocPages; | | | |
| | | | |
| /// whether Sidplayer routine has been installed | | | |
| bool musPlayer; | | | |
| | | | |
| /// Sid Model required for first sid | | | |
| int sidModel1; | | | |
| | | | |
| /// Sid Model required for second sid | | | |
| int sidModel2; | | | |
| | | | |
| /// compatibility requirements | | | |
| int compatibility; | | | |
| | | | |
| /// whether load address might be duplicate | | | |
| bool fixLoad; | | | |
| | | | |
| /// --- not yet supported --- | | | |
| uint_least16_t songLength; | | | |
| | | | |
| /// the number of available text info lines | | | |
| uint_least8_t numberOfInfoStrings; | | | |
| | | | |
| /** | | | |
| * Song title, credits, ... | | | |
| * 0 = Title, 1 = Author, 2 = Copyright/Publisher | | | |
| */ | | | |
| char* infoString[SIDTUNE_MAX_CREDIT_STRINGS]; | | | |
| | | | |
| /// --- not yet supported --- | | | |
| uint_least16_t numberOfCommentStrings; | | | |
| | | | |
| /// --- not yet supported --- | | | |
| char ** commentString; | | | |
| | | | |
| /// length of single-file sidtune file | | | |
| uint_least32_t dataFileLen; | | | |
| | | | |
| /// length of raw C64 data without load address | | | |
| uint_least32_t c64dataLen; | | | |
| | | | |
| /// path to sidtune files; "", if cwd | | | |
| char* path; | | | |
| | | | |
|
| /// a first file: e.g. "foo.c64"; "", if none | | private: // ------------------------------------------------------------- | |
| char* dataFileName; | | std::auto_ptr<SidTuneBase> tune; | |
| | | | |
|
| /// a second file: e.g. "foo.sid"; "", if none | | const char* m_statusString; | |
| char* infoFileName; | | | |
| }; | | | |
| | | | |
|
| /** | | bool m_status; | |
| * SidTune | | | |
| */ | | | |
| class SID_EXTERN SidTune | | | |
| { | | | |
| private: | | | |
| typedef enum | | | |
| { | | | |
| LOAD_NOT_MINE = 0, | | | |
| LOAD_OK, | | | |
| LOAD_ERROR | | | |
| } LoadStatus; | | | |
| | | | |
|
| 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 ``sidTuneFileName'' | | * 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 specific ``sidTuneFileName = 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 fileNameExt | |
| | | * @param separatorIsSlash | |
| */ | | */ | |
| SidTune(const char* fileName, const char **fileNameExt = 0, | | SidTune(const char* fileName, const char **fileNameExt = 0, | |
|
| const 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 sidtuneLength length of the buffer | |
| */ | | */ | |
|
| SidTune(const uint_least8_t* oneFileFormatSidtune, const uint_least32_t
sidtuneLength); | | 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 | |
| */ | | */ | |
| void setFileNameExtensions(const char **fileNameExt); | | void setFileNameExtensions(const char **fileNameExt); | |
| | | | |
| /** | | /** | |
|
| * Load a sidtune into an existing object. | | * Load a sidtune into an existing object from a file. | |
| * From a file. | | * | |
| */ | | * @param fileName | |
| bool load(const char* fileName, const bool separatorIsSlash = false); | | * @param separatorIsSlash | |
| | | | |
| /** | | | |
| * From a buffer. | | | |
| */ | | */ | |
|
| bool read(const uint_least8_t* sourceBuffer, const uint_least32_t buffe
rLen); | | void load(const char* fileName, bool separatorIsSlash = false); | |
| | | | |
| /** | | /** | |
|
| * Select sub-song (0 = default starting song) | | * Load a sidtune into an existing object from a buffer. | |
| * and retrieve active song information. | | * | |
| | | * @param sourceBuffer the buffer that contains song data | |
| | | * @param bufferLen length of the buffer | |
| */ | | */ | |
|
| const SidTuneInfo& operator[](const uint_least16_t songNum); | | void read(const uint_least8_t* sourceBuffer, uint_least32_t bufferLen); | |
| | | | |
| /** | | /** | |
|
| * Select sub-song (0 = default starting song) | | * Select sub-song. | |
| * and return active song number out of [1,2,..,SIDTUNE_MAX_SONGS]. | | * | |
| | | * @param songNum the selected song (0 = default starting song) | |
| | | * @return active song number, 0 if no tune is loaded. | |
| */ | | */ | |
|
| uint_least16_t selectSong(const uint_least16_t songNum); | | unsigned int selectSong(unsigned int songNum); | |
| | | | |
| /** | | /** | |
|
| * Retrieve sub-song specific information. | | * Retrieve current active sub-song specific information. | |
| * Beware! Still member-wise copy! | | * | |
| | | * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The pointe | |
| | | r must not be deleted. | |
| */ | | */ | |
|
| const SidTuneInfo& getInfo(); | | const SidTuneInfo* getInfo() const; | |
| | | | |
| /** | | /** | |
|
| * Get a copy of sub-song specific information. | | * Select sub-song and retrieve information. | |
| * Beware! Still member-wise copy! | | * | |
| | | * @param songNum the selected song (0 = default starting song) | |
| | | * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The pointe | |
| | | r must not be deleted. | |
| */ | | */ | |
|
| void getInfo(SidTuneInfo&); | | const SidTuneInfo* getInfo(unsigned int songNum); | |
| | | | |
| /** | | /** | |
|
| * Determine current state of object (true = okay, false = error). | | * Determine current state of object. | |
| * Upon error condition use ``getInfo'' to get a descriptive | | * Upon error condition use #statusString to get a descriptive | |
| * text string in ``SidTuneInfo.statusString''. | | * text string. | |
| | | * | |
| | | * @return current state (true = okay, false = error) | |
| */ | | */ | |
|
| operator bool() { return status; } | | bool getStatus() const; | |
| bool getStatus() { return status; } | | | |
| | | | |
| /** | | /** | |
|
| * Whether sidtune uses two SID chips. | | * Error/status message of last operation | |
| */ | | */ | |
|
| bool isStereo() | | const char* statusString() const; | |
| { | | | |
| return (info.sidChipBase1!=0 && info.sidChipBase2!=0); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Copy sidtune into C64 memory (64 KB). | | * Copy sidtune into C64 memory (64 KB). | |
| */ | | */ | |
|
| bool placeSidTuneInC64mem(uint_least8_t* c64buf); | | bool placeSidTuneInC64mem(sidmemory* mem); | |
| | | | |
| // --- file save & format conversion --- | | | |
| | | | |
| /** | | | |
| * These functions work for any successfully created object. | | | |
| * overWriteFlag: true = Overwrite existing file. | | | |
| * false = Default, return error when file already | | | |
| * exists. | | | |
| * One could imagine an "Are you sure ?"-checkbox before overwriting | | | |
| * any file. | | | |
| * returns: true = Successful, false = Error condition. | | | |
| */ | | | |
| bool saveC64dataFile( const char* destFileName, const bool overWriteFla | | | |
| g = false ); | | | |
| bool saveSIDfile( const char* destFileName, const bool overWriteFlag = | | | |
| false ); | | | |
| bool savePSIDfile( const char* destFileName, const bool overWriteFlag = | | | |
| false ); | | | |
| | | | |
| /** | | /** | |
|
| * This function can be used to remove a duplicate C64 load address in | | * Calculates the MD5 hash of the tune. | |
| * the C64 data (example: FE 0F 00 10 4C ...). A duplicate load address | | * Not providing an md5 buffer will cause the internal one to be used. | |
| * of offset 0x02 is indicated by the ``fixLoad'' flag in the SidTuneInf | | * If provided, buffer must be MD5_LENGTH + 1 | |
| o | | | |
| * structure. | | | |
| * | | * | |
|
| * The ``force'' flag here can be used to remove the first load address | | * @return a pointer to the buffer containing the md5 string, 0 if no tu | |
| * and set new INIT/PLAY addresses regardless of whether a duplicate | | ne is loaded. | |
| * load address has been detected and indicated by ``fixLoad''. | | | |
| * For instance, some position independent sidtunes contain a load addre | | | |
| ss | | | |
| * of 0xE000, but are loaded to 0x0FFE and call the player code at 0x100 | | | |
| 0. | | | |
| * | | | |
| * Do not forget to save the sidtune file. | | | |
| */ | | | |
| void fixLoadAddress(const bool force = false, uint_least16_t initAddr = | | | |
| 0, | | | |
| uint_least16_t playAddr = 0); | | | |
| | | | |
| /** | | | |
| * Does not affect status of object, and therefore can be used | | | |
| * to load files. Error string is put into info.statusString, though. | | | |
| */ | | | |
| bool loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& | | | |
| bufferRef); | | | |
| | | | |
| bool saveToOpenFile( std::ofstream& toFile, const uint_least8_t* buffer | | | |
| , uint_least32_t bufLen ); | | | |
| | | | |
| protected: // ----------------------------------------------------------- | | | |
| -- | | | |
| | | | |
| SidTuneInfo info; | | | |
| bool status; | | | |
| | | | |
| uint_least8_t songSpeed[SIDTUNE_MAX_SONGS]; | | | |
| uint_least8_t clockSpeed[SIDTUNE_MAX_SONGS]; | | | |
| uint_least16_t songLength[SIDTUNE_MAX_SONGS]; | | | |
| | | | |
| /// holds text info from the format headers etc. | | | |
| char infoString[SIDTUNE_MAX_CREDIT_STRINGS][SIDTUNE_MAX_CREDIT_STRLEN]; | | | |
| | | | |
| /** | | | |
| * If your opendir() and readdir()->d_name return path names | | | |
| * that contain the forward slash (/) as file separator, but | | | |
| * your operating system uses a different character, there are | | | |
| * extra functions that can deal with this special case. Set | | | |
| * separatorIsSlash to true if you like path names to be split | | | |
| * correctly. | | | |
| * You do not need these extra functions if your systems file | | | |
| * separator is the forward slash. | | | |
| */ | | */ | |
|
| bool isSlashedFileName; | | const char *createMD5(char *md5 = 0); | |
| | | | |
| /// For files with header: offset to real data | | | |
| uint_least32_t fileOffset; | | | |
| | | | |
| /// Needed for MUS/STR player installation. | | | |
| uint_least16_t musDataLen; | | | |
| | | | |
| Buffer_sidtt<const uint_least8_t> cache; | | | |
| | | | |
| /// Filename extensions to append for various file types. | | | |
| static const char** fileNameExtensions; | | | |
| | | | |
| // --- protected member functions --- | | | |
| | | | |
| /// Convert 32-bit PSID-style speed word to internal tables. | | | |
| void convertOldStyleSpeedToTables(uint_least32_t speed, | | | |
| int clock = SIDTUNE_CLOCK_PAL); | | | |
| | | | |
| virtual int convertPetsciiToAscii (SmartPtr_sidtt<const uint_least8_t>& | | | |
| , char*); | | | |
| | | | |
| /// Check compatibility details are sensible | | | |
| bool checkCompatibility(void); | | | |
| /// Check for valid relocation information | | | |
| bool checkRelocInfo(void); | | | |
| /// Common address resolution procedure | | | |
| bool resolveAddrs(const uint_least8_t* c64data); | | | |
| | | | |
| // Support for various file formats. | | | |
| | | | |
| virtual LoadStatus PSID_fileSupport (Buffer_sidtt<const uint_least8_ | | | |
| t>& dataBuf); | | | |
| virtual bool PSID_fileSupportSave(std::ofstream& toFile, const ui | | | |
| nt_least8_t* dataBuffer); | | | |
| | | | |
| virtual LoadStatus SID_fileSupport (Buffer_sidtt<const uint_least8_ | | | |
| t>& dataBuf, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& sidBuf); | | | |
| virtual bool SID_fileSupportSave (std::ofstream& toFile); | | | |
| | | | |
| virtual LoadStatus MUS_fileSupport (Buffer_sidtt<const uint_least8_ | | | |
| t>& musBuf, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& strBuf); | | | |
| LoadStatus MUS_load (Buffer_sidtt<const uint_least8_ | | | |
| t>& musBuf, | | | |
| bool init = false); | | | |
| LoadStatus MUS_load (Buffer_sidtt<const uint_least8_ | | | |
| t>& musBuf, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& strBuf, | | | |
| bool init = false); | | | |
| virtual bool MUS_detect (const void* buffer, const uint_ | | | |
| least32_t bufLen, | | | |
| uint_least32_t& voice3Index); | | | |
| virtual bool MUS_mergeParts (Buffer_sidtt<const uint_least8_ | | | |
| t>& musBuf, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& strBuf); | | | |
| virtual void MUS_setPlayerAddress(); | | | |
| virtual void MUS_installPlayer (uint_least8_t *c64buf); | | | |
| | | | |
| virtual LoadStatus INFO_fileSupport (Buffer_sidtt<const uint_least8_ | | | |
| t>& dataBuf, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& infoBuf); | | | |
| virtual LoadStatus PRG_fileSupport (const char* fileName, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& dataBuf); | | | |
| virtual LoadStatus X00_fileSupport (const char* fileName, | | | |
| Buffer_sidtt<const uint_least8_ | | | |
| t>& dataBuf); | | | |
| | | | |
| /// @name Error and status message strings. | | | |
| //@{ | | | |
| static const char* txt_songNumberExceed; | | | |
| static const char* txt_empty; | | | |
| static const char* txt_unrecognizedFormat; | | | |
| static const char* txt_noDataFile; | | | |
| static const char* txt_notEnoughMemory; | | | |
| static const char* txt_cantLoadFile; | | | |
| static const char* txt_cantOpenFile; | | | |
| static const char* txt_fileTooLong; | | | |
| static const char* txt_dataTooLong; | | | |
| static const char* txt_cantCreateFile; | | | |
| static const char* txt_fileIoError; | | | |
| static const char* txt_VBI; | | | |
| static const char* txt_CIA; | | | |
| static const char* txt_noErrors; | | | |
| static const char* txt_na; | | | |
| static const char* txt_badAddr; | | | |
| static const char* txt_badReloc; | | | |
| static const char* txt_corrupt; | | | |
| //@} | | | |
| | | | |
| private: // ------------------------------------------------------------- | | | |
| -- | | | |
| | | | |
| void init(); | | | |
| void cleanup(); | | | |
| #if !defined(SIDTUNE_NO_STDIN_LOADER) | | | |
| void getFromStdIn(); | | | |
| #endif | | | |
| void getFromFiles(const char* name); | | | |
| | | | |
| void deleteFileNameCopies(); | | | |
| | | | |
| /// Try to retrieve single-file sidtune from specified buffer. | | | |
| void getFromBuffer(const uint_least8_t* const buffer, const uint_least3 | | | |
| 2_t bufferLen); | | | |
| | | | |
| /** | | | |
| * Cache the data of a single-file or two-file sidtune and its | | | |
| * corresponding file names. | | | |
| */ | | | |
| bool acceptSidTune(const char* dataFileName, const char* infoFileName, | | | |
| Buffer_sidtt<const uint_least8_t>& buf); | | | |
| | | | |
| bool createNewFileName(Buffer_sidtt<char>& destString, | | | |
| const char* sourceName, const char* sourceExt); | | | |
| | | | |
| int decompressPP20(Buffer_sidtt<const uint_least8_t>& buf); | | | |
| | | | |
|
| 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. 45 change blocks. |
| 406 lines changed or deleted | | 95 lines changed or added | |
|
| event.h | | event.h | |
|
| /************************************************************************** | | /* | |
| * | | * This file is part of libsidplayfp, a SID player engine. | |
| event.h - Event scheduler (based on alarm | | * | |
| from Vice) | | * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> | |
| ------------------- | | * Copyright 2007-2010 Antti Lankila | |
| begin : Wed May 9 2001 | | * Copyright 2001 Simon White | |
| copyright : (C) 2001 by Simon White | | * | |
| email : s_a_white@email.com | | * This program is free software; you can redistribute it and/or modify | |
| ************************************************************************** | | * it under the terms of the GNU General Public License as published by | |
| */ | | * the Free Software Foundation; either version 2 of the License, or | |
| | | * (at your option) any later version. | |
| /************************************************************************** | | * | |
| * | | * This program is distributed in the hope that it will be useful, | |
| * | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * This program is free software; you can redistribute it and/or modify | | * GNU General Public License for more details. | |
| * | | * | |
| * it under the terms of the GNU General Public License as published by | | * You should have received a copy of the GNU General Public License | |
| * | | * along with this program; if not, write to the Free Software | |
| * the Free Software Foundation; either version 2 of the License, or | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 | |
| * | | 1, USA. | |
| * (at your option) any later version. | | */ | |
| * | | | |
| * | | | |
| * | | | |
| ************************************************************************** | | | |
| */ | | | |
| | | | |
|
| #ifndef _event_h_ | | #ifndef EVENT_H | |
| #define _event_h_ | | #define EVENT_H | |
| | | | |
|
| #include "sidtypes.h" | | #include <stdint.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; | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 54 | |
| * Optimized EventScheduler and corresponding Event class by Antti S. Lankil
a | | * Optimized EventScheduler and corresponding Event class by Antti S. Lankil
a | |
| * 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: | |
|
| class EventContext *m_context SID_DEPRECATED; | | | |
| | | | |
| /** 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; | |
| | | | |
|
| /** | | | |
| * This variable is set by the event context | | | |
| * when it is scheduled | | | |
| */ | | | |
| bool m_pending; | | | |
| | | | |
| /** 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) {} | |
| m_pending(false) {} | | | |
| ~Event() {} | | | |
| | | | |
| /** | | /** | |
| * 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 (void) = 0; | | virtual void event() = 0; | |
| | | | |
| /** Is Event scheduled? */ | | | |
| bool pending () const { return m_pending; } | | | |
| | | | |
| /** | | | |
| * Cancel the specified event. | | | |
| * | | | |
| * @deprecated use EventContext::cancel | | | |
| */ | | | |
| SID_DEPRECATED void cancel (); | | | |
| | | | |
|
| /** | | protected: | |
| * Add event to pending queue. | | ~Event() {} | |
| * | | | |
| * @deprecated use EventContext::schedule | | | |
| */ | | | |
| SID_DEPRECATED void schedule(EventContext &context, event_clock_t cy | | | |
| cles, | | | |
| event_phase_t phase); | | | |
| }; | | | |
| | | | |
| template< class This > | | | |
| class EventCallback: public Event | | | |
| { | | | |
| private: | | | |
| typedef void (This::*Callback) (); | | | |
| This &m_this; | | | |
| Callback const m_callback; | | | |
| void event(void) { (m_this.*m_callback) (); } | | | |
| | | | |
| public: | | | |
| EventCallback (const char * const name, This &_this, Callback callback) | | | |
| : Event(name), m_this(_this), | | | |
| m_callback(callback) {} | | | |
| }; | | | |
| | | | |
| // Public Event Context | | | |
| class EventContext | | | |
| { | | | |
| friend class Event; | | | |
| | | | |
| public: | | | |
| virtual void cancel (Event &event) = 0; | | | |
| virtual void schedule (Event &event, const event_clock_t cycles, | | | |
| const event_phase_t phase) = 0; | | | |
| virtual void schedule (Event &event, const event_clock_t cycles) = 0; | | | |
| virtual event_clock_t getTime (const event_phase_t phase) const = 0; | | | |
| virtual event_clock_t getTime (const event_clock_t clock, const event_p | | | |
| hase_t phase) const = 0; | | | |
| virtual event_phase_t phase () const = 0; | | | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * 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 cycle. (This behavior may be a bug of the | | * event to be moved to the next phi1 cycle. Correspondingly, requesting | |
| * original EventScheduler specification. Likely reason is to avoid | | * a phi1 time when system is in phi2 returns the value of the next phi1. | |
| * scheduling an event into past.) | | | |
| * | | | |
| * Getting a phi1 time when system is in phi2 causes the next phi1 clock | | | |
| * to be returned. | | | |
| * | | | |
| * To make scheduling even faster, I am considering making event cancellatio | | | |
| n | | | |
| * before rescheduling mandatory, as caller is generally in position to | | | |
| * automatically know if the event needs to be canceled first. | | | |
| * | | * | |
| * @author Antti S. Lankila | | * @author Antti S. Lankila | |
| */ | | */ | |
|
| class EventScheduler: public EventContext | | class EventContext | |
| { | | { | |
|
| private: | | public: | |
| event_clock_t currentTime; | | | |
| Event *firstEvent; | | | |
| | | | |
| private: | | | |
| void event (void); | | | |
| | | | |
| /** | | /** | |
|
| * Scan the event queue and schedule event for execution. | | * Cancel the specified event. | |
| * | | * | |
|
| * @param event The event to add | | * @param event the event to cancel | |
| */ | | */ | |
|
| void schedule(Event &event) { | | virtual void cancel(Event &event) = 0; | |
| | | | |
| if (event.m_pending) | | | |
| cancel(event); | | | |
| | | | |
| event.m_pending = true; | | | |
| | | | |
| /* find the right spot where to tuck this new event */ | | | |
| Event **scan = &firstEvent; | | | |
| for (;;) { | | | |
| if (*scan == 0 || (*scan)->triggerTime > event.triggerTime) { | | | |
| event.next = *scan; | | | |
| *scan = &event; | | | |
| break; | | | |
| } | | | |
| scan = &((*scan)->next); | | | |
| } | | | |
| } | | | |
| | | | |
|
| protected: | | /** | |
| /** 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 | |
| | | 1. | |
| * | | * | |
| * @param event the event to add | | * @param event the event to add | |
|
| * @param cycles the clock to fire | | * @param cycles how many cycles from now to fire | |
| * @param phase when to fire the event | | * @param phase the phase when to fire the event | |
| */ | | */ | |
|
| void schedule (Event &event, const event_clock_t cycles, | | virtual void schedule(Event &event, event_clock_t cycles, | |
| const event_phase_t phase) { | | event_phase_t phase) = 0; | |
| // this strange formulation always selects the next available slot | | | |
| regardless of specified phase. | | | |
| event.triggerTime = (cycles << 1) + currentTime + ((currentTime & 1 | | | |
| ) ^ phase); | | | |
| schedule(event); | | | |
| } | | | |
| | | | |
|
| /** 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 | |
| */ | | */ | |
|
| void schedule(Event &event, const event_clock_t cycles) { | | virtual void schedule(Event &event, event_clock_t cycles) = 0; | |
| event.triggerTime = (cycles << 1) + currentTime; | | | |
| schedule(event); | | | |
| } | | | |
| | | | |
|
| /** Cancel the specified event. | | /** | |
| | | * Is the event pending in this scheduler? | |
| * | | * | |
|
| * @param event the event to cancel | | * @param event the event | |
| | | * @return true when pending | |
| */ | | */ | |
|
| void cancel (Event &event); | | virtual bool isPending(Event &event) const = 0; | |
| | | | |
|
| public: | | /** | |
| EventScheduler () | | * Get time with respect to a specific clock phase. | |
| : currentTime(0), | | | |
| firstEvent(0) {} | | | |
| | | | |
| /** Cancel all pending events and reset time. */ | | | |
| void reset (void); | | | |
| | | | |
| /** Fire next event, advance system time to that event */ | | | |
| void clock (void) | | | |
| { | | | |
| Event &event = *firstEvent; | | | |
| firstEvent = firstEvent->next; | | | |
| event.m_pending = false; | | | |
| currentTime = event.triggerTime; | | | |
| event.event(); | | | |
| } | | | |
| | | | |
| /** 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. | |
| */ | | */ | |
|
| event_clock_t getTime (const event_phase_t phase) const | | virtual event_clock_t getTime(event_phase_t phase) const = 0; | |
| { return (currentTime + (phase ^ 1)) >> 1; } | | | |
| | | | |
|
| /** 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 | |
| */ | | */ | |
|
| event_clock_t getTime (const event_clock_t clock, const event_phase_t p | | virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) | |
| hase) const | | const = 0; | |
| { return getTime (phase) - clock; } | | | |
| | | | |
|
| /** Return current clock phase | | /** | |
| | | * Return current clock phase. | |
| * | | * | |
| * @return The current phase | | * @return The current phase | |
| */ | | */ | |
|
| event_phase_t phase () const { return (event_phase_t) (currentTime & 1) | | virtual event_phase_t phase() const = 0; | |
| ; } | | | |
| }; | | | |
| | | | |
| inline void Event::schedule (EventContext &context, event_clock_t cycles, | | | |
| event_phase_t phase) | | | |
| { | | | |
| m_context = &context; | | | |
| m_context->schedule (*this, cycles, phase); | | | |
| } | | | |
| | | | |
|
| inline void Event::cancel () | | protected: | |
| { | | ~EventContext() {} | |
| if (m_pending) | | }; | |
| m_context->cancel (*this); | | | |
| } | | | |
| | | | |
|
| #endif // _event_h_ | | #endif // EVENT_H | |
| | | | |
End of changes. 30 change blocks. |
| 192 lines changed or deleted | | 69 lines changed or added | |
|
| residfp.h | | residfp.h | |
|
| /************************************************************************** | | /* | |
| * | | * This file is part of libsidplayfp, a SID player engine. | |
| resid.h - ReSid Builder | | * | |
| ------------------- | | * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> | |
| begin : Fri Apr 4 2001 | | * Copyright 2007-2010 Antti Lankila | |
| copyright : (C) 2001 by Simon White | | * Copyright 2001 Simon White | |
| email : s_a_white@email.com | | * | |
| ************************************************************************** | | * This program is free software; you can redistribute it and/or modify | |
| */ | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| /************************************************************************** | | * (at your option) any later version. | |
| * | | * | |
| * | | * This program is distributed in the hope that it will be useful, | |
| * | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * This program is free software; you can redistribute it and/or modify | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * | | * GNU General Public License for more details. | |
| * it under the terms of the GNU General Public License as published by | | * | |
| * | | * You should have received a copy of the GNU General Public License | |
| * the Free Software Foundation; either version 2 of the License, or | | * along with this program; if not, write to the Free Software | |
| * | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 | |
| * (at your option) any later version. | | 1, USA. | |
| * | | | |
| * | | | |
| * | | | |
| ************************************************************************** | | | |
| */ | | | |
| | | | |
| #ifndef _residfp_h_ | | | |
| #define _residfp_h_ | | | |
| | | | |
| /* Since ReSID is not part of this project we are actually | | | |
| * creating a wrapper instead of implementing a SID emulation | | | |
| */ | | */ | |
| | | | |
|
| #include <vector> | | #ifndef RESIDFP_H | |
| | | #define RESIDFP_H | |
| | | | |
| #include "sidplayfp/sidbuilder.h" | | #include "sidplayfp/sidbuilder.h" | |
|
| | | #include "sidplayfp/siddefs.h" | |
| | | | |
| /** | | /** | |
| * ReSIDfp Builder Class | | * ReSIDfp Builder Class | |
| */ | | */ | |
| class SID_EXTERN ReSIDfpBuilder: public sidbuilder | | class SID_EXTERN ReSIDfpBuilder: public sidbuilder | |
| { | | { | |
|
| protected: | | | |
| std::vector<sidemu *> sidobjs; | | | |
| | | | |
| private: | | | |
| static const char *ERR_FILTER_DEFINITION; | | | |
| const char *m_error; | | | |
| char m_errorBuffer[100]; | | | |
| | | | |
| public: | | public: | |
|
| ReSIDfpBuilder (const char * const name); | | ReSIDfpBuilder(const char * const name) : | |
| ~ReSIDfpBuilder (void); | | sidbuilder(name) {} | |
| | | ~ReSIDfpBuilder(); | |
| | | | |
| | | /** | |
| | | * Available sids. | |
| | | * | |
| | | * @return the number of available sids, 0 = endless. | |
| | | */ | |
| | | unsigned int availDevices() const { return 0; } | |
| | | | |
| /** | | /** | |
|
| * true will give you the number of used devices. | | * Create the sid emu. | |
| * return values: 0 none, positive is used sids | | * | |
| * false will give you all available sids. | | * @param sids the number of required sid emu | |
| * return values: 0 endless, positive is available sids. | | | |
| * use bool operator to determine error | | | |
| */ | | */ | |
|
| uint devices (bool used); | | unsigned int create(unsigned int sids); | |
| uint create (uint sids); | | | |
| sidemu *lock (c64env *env, sid2_model_t model); | | const char *credits() const; | |
| void unlock (sidemu *device); | | | |
| void remove (void); | | | |
| const char *error (void) const { return m_error; } | | | |
| const char *credits (void); | | | |
| | | | |
| /// @name global settings | | /// @name global settings | |
|
| /// Settings that affect all SIDs | | /// Settings that affect all SIDs. | |
| //@{ | | //@{ | |
|
| /// enable/disable filter | | /// enable/disable filter. | |
| void filter (bool enable); | | void filter(bool enable); | |
| | | | |
| /// @deprecated does nothing | | | |
| SID_DEPRECATED void filter (const sid_filterfp_t *filter) {}; | | | |
| | | | |
| /** | | /** | |
|
| * Set 6581 filter curve | | * Set 6581 filter curve. | |
| * | | * | |
| * @param filterCurve from 0.0 (light) to 1.0 (dark) (default 0.5) | | * @param filterCurve from 0.0 (light) to 1.0 (dark) (default 0.5) | |
| */ | | */ | |
|
| void filter6581Curve (const double filterCurve); | | void filter6581Curve(double filterCurve); | |
| | | | |
| /** | | /** | |
|
| * Set 8580 filter curve | | * Set 8580 filter curve. | |
| * | | * | |
| * @param filterCurve curve center frequency (default 12500) | | * @param filterCurve curve center frequency (default 12500) | |
| */ | | */ | |
|
| void filter8580Curve (const double filterCurve); | | void filter8580Curve(double filterCurve); | |
| //@} | | //@} | |
| }; | | }; | |
| | | | |
|
| #endif // _resid_h_ | | #endif // RESIDFP_H | |
| | | | |
End of changes. 14 change blocks. |
| 65 lines changed or deleted | | 48 lines changed or added | |
|
| sidbuilder.h | | sidbuilder.h | |
|
| /************************************************************************** | | /* | |
| * | | * This file is part of libsidplayfp, a SID player engine. | |
| sidbuilder.h - Sid Builder Classes | | * | |
| ------------------- | | * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> | |
| begin : Sat May 6 2001 | | * Copyright 2007-2010 Antti Lankila | |
| copyright : (C) 2000 by Simon White | | * Copyright 2000-2001 Simon White | |
| email : s_a_white@email.com | | * | |
| ************************************************************************** | | * This program is free software; you can redistribute it and/or modify | |
| */ | | * it under the terms of the GNU General Public License as published by | |
| | | * the Free Software Foundation; either version 2 of the License, or | |
| /************************************************************************** | | * (at your option) any later version. | |
| * | | * | |
| * | | * This program is distributed in the hope that it will be useful, | |
| * | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * This program is free software; you can redistribute it and/or modify | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * | | * GNU General Public License for more details. | |
| * it under the terms of the GNU General Public License as published by | | * | |
| * | | * You should have received a copy of the GNU General Public License | |
| * the Free Software Foundation; either version 2 of the License, or | | * along with this program; if not, write to the Free Software | |
| * | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 | |
| * (at your option) any later version. | | 1, USA. | |
| * | | */ | |
| * | | | |
| * | | #ifndef SIDBUILDER_H | |
| ************************************************************************** | | #define SIDBUILDER_H | |
| */ | | | |
| | | #include <set> | |
| #ifndef _sidbuilder_h_ | | #include <string> | |
| #define _sidbuilder_h_ | | | |
| | | #include "sidplayfp/SidConfig.h" | |
| #include "sid2types.h" | | | |
| #include "component.h" | | class sidemu; | |
| #include "c64env.h" | | class EventContext; | |
| | | | |
| // Inherit this class to create a new SID emulations for libsidplay2. | | /** | |
| class sidbuilder; | | * Base class for sid builders. | |
| class sidemu: public component | | */ | |
| | | class sidbuilder | |
| { | | { | |
| private: | | private: | |
|
| sidbuilder *m_builder; | | const char * const m_name; | |
| | | | |
| protected: | | protected: | |
|
| int m_bufferpos; | | std::string m_errorBuffer; | |
| short *m_buffer; | | | |
| | | | |
| public: | | | |
| sidemu (sidbuilder *builder) | | | |
| : m_builder (builder) {;} | | | |
| virtual ~sidemu () {;} | | | |
| | | | |
| // Standard component functions | | | |
| void reset () { reset (0); } | | | |
| virtual void reset (uint8_t volume) = 0; | | | |
| virtual uint8_t read (uint_least8_t addr) = 0; | | | |
| virtual void write (uint_least8_t addr, uint8_t data) = 0; | | | |
| virtual void clock() = 0; | | | |
| virtual const char *credits (void) = 0; | | | |
| | | | |
| // Standard SID functions | | | |
| virtual void voice (uint_least8_t num, bool mute) = 0; | | | |
| sidbuilder *builder (void) const { return m_builder; } | | | |
| | | | |
| virtual int bufferpos() { return m_bufferpos; } | | | |
| virtual void bufferpos(int pos) { m_bufferpos = pos; } | | | |
| virtual short *buffer() { return m_buffer; } | | | |
| | | | |
|
| virtual void sampling(float systemfreq, float outputfreq, | | std::set<sidemu *> sidobjs; | |
| const sampling_method_t method, const bool fast) { return; } | | | |
| }; | | | |
| | | | |
|
| class sidbuilder | | bool m_status; | |
| { | | | |
| private: | | | |
| const char * const m_name; | | | |
| | | | |
| protected: | | protected: | |
|
| bool m_status; | | /** | |
| | | * Utility class for setting emu parameters in builders. | |
| | | */ | |
| | | template<class Temu, typename Tparam> | |
| | | class applyParameter | |
| | | { | |
| | | protected: | |
| | | Tparam m_param; | |
| | | void (Temu::*m_method)(Tparam); | |
| | | | |
| | | public: | |
| | | applyParameter(void (Temu::*method)(Tparam), Tparam param) : | |
| | | m_param(param), | |
| | | m_method(method) {} | |
| | | void operator() (sidemu *e) { (static_cast<Temu*>(e)->*m_method)(m_ | |
| | | param); } | |
| | | }; | |
| | | | |
| public: | | public: | |
|
| sidbuilder(const char * const name) | | sidbuilder(const char * const name) : | |
| : m_name(name), m_status (true) {;} | | m_name(name), | |
| virtual ~sidbuilder() {;} | | m_errorBuffer("N/A"), | |
| | | m_status (true) {} | |
| virtual sidemu *lock (c64env *env, sid2_model_t model) = 0; | | virtual ~sidbuilder() {} | |
| virtual void unlock (sidemu *device) = 0; | | | |
| const char *name (void) const { return m_name; } | | /** | |
| virtual const char *error (void) const = 0; | | * The number of used devices. | |
| virtual const char *credits (void) = 0; | | * | |
| virtual void filter (bool enable) = 0; | | * @return number of used sids, 0 if none. | |
| | | */ | |
| // Determine current state of object (true = okay, false = error). | | unsigned int usedDevices() const { return sidobjs.size (); } | |
| operator bool() const { return m_status; } | | | |
| | | /** | |
| | | * Available devices. | |
| | | * | |
| | | * @return the number of available sids, 0 = endless. | |
| | | */ | |
| | | virtual unsigned int availDevices() const = 0; | |
| | | | |
| | | /** | |
| | | * Create the sid emu. | |
| | | * | |
| | | * @param sids the number of required sid emu | |
| | | */ | |
| | | virtual unsigned int create(unsigned int sids) = 0; | |
| | | | |
| | | /** | |
| | | * Find a free SID of the required specs | |
| | | * | |
| | | * @param env the event context | |
| | | * @param model the required sid model | |
| | | * @return pointer to the locked sid emu | |
| | | */ | |
| | | sidemu *lock(EventContext *env, SidConfig::sid_model_t model); | |
| | | | |
| | | /** | |
| | | * Release this SID. | |
| | | * | |
| | | * @param device the sid emu to unlock | |
| | | */ | |
| | | void unlock(sidemu *device); | |
| | | | |
| | | /** | |
| | | * Remove all SID emulations. | |
| | | */ | |
| | | void remove(); | |
| | | | |
| | | /** | |
| | | * Get the builder's name. | |
| | | * | |
| | | * @return the name | |
| | | */ | |
| | | const char *name() const { return m_name; } | |
| | | | |
| | | /** | |
| | | * Error message. | |
| | | * | |
| | | * @return string error message. | |
| | | */ | |
| | | const char *error() const { return m_errorBuffer.c_str(); } | |
| | | | |
| | | /** | |
| | | * Determine current state of object. | |
| | | * | |
| | | * @return true = okay, false = error | |
| | | */ | |
| | | bool getStatus() const { return m_status; } | |
| | | | |
| | | /** | |
| | | * Get the builder's credits. | |
| | | * | |
| | | * @return credits | |
| | | */ | |
| | | virtual const char *credits() const = 0; | |
| | | | |
| | | /** | |
| | | * Toggle sid filter emulation. | |
| | | * | |
| | | * @param enable true = enable, false = disable | |
| | | */ | |
| | | virtual void filter(bool enable) = 0; | |
| }; | | }; | |
| | | | |
|
| #endif // _sidbuilder_h_ | | #endif // SIDBUILDER_H | |
| | | | |
End of changes. 8 change blocks. |
| 82 lines changed or deleted | | 141 lines changed or added | |
|