00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SIDTUNEBASE_H
00024 #define SIDTUNEBASE_H
00025
00026 #include <stdint.h>
00027 #include <fstream>
00028 #include <memory>
00029
00030 #include "sidplayfp/Buffer.h"
00031 #include "sidplayfp/SmartPtr.h"
00032 #include "sidplayfp/SidTuneInfo.h"
00033 #include "sidplayfp/SidTune.h"
00034 #include "sidplayfp/siddefs.h"
00035
00036 template class Buffer_sidtt<const uint_least8_t>;
00037
00038 class SidTuneInfoImpl;
00039
00043 class loadError
00044 {
00045 private:
00046 const char* m_msg;
00047 public:
00048 loadError(const char* msg) : m_msg(msg) {}
00049 const char* message() const { return m_msg; }
00050 };
00051
00055 class SidTuneBase
00056 {
00057 protected:
00059 static const unsigned int MAX_SONGS = 256;
00060
00061 private:
00063 static const uint_least32_t MAX_FILELEN = 65536+2+0x7C;
00064
00065 static const uint_least32_t MAX_MEMORY = 65536;
00066
00067 public:
00068 virtual ~SidTuneBase() {}
00069
00080 static SidTuneBase* load(const char* fileName, const char **fileNameExt, bool separatorIsSlash);
00081
00086 static SidTuneBase* read(const uint_least8_t* sourceBuffer, uint_least32_t bufferLen);
00087
00092 unsigned int selectSong(unsigned int songNum);
00093
00097 const SidTuneInfo* getInfo() const;
00098
00103 const SidTuneInfo* getInfo(unsigned int songNum);
00104
00108 virtual bool placeSidTuneInC64mem(sidmemory* mem);
00109
00116 virtual const char *createMD5(char *md5 SID_UNUSED) { return 0; }
00117
00118 protected:
00119
00120 std::auto_ptr<SidTuneInfoImpl> info;
00121
00122 uint_least8_t songSpeed[MAX_SONGS];
00123 SidTuneInfo::clock_t clockSpeed[MAX_SONGS];
00124
00126 uint_least32_t fileOffset;
00127
00128 Buffer_sidtt<const uint_least8_t> cache;
00129
00130 protected:
00131 SidTuneBase();
00132
00137 static void loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& bufferRef);
00138
00140 void convertOldStyleSpeedToTables(uint_least32_t speed,
00141 SidTuneInfo::clock_t clock = SidTuneInfo::CLOCK_PAL);
00142
00144 bool checkCompatibility();
00145
00147 bool checkRelocInfo();
00148
00150 void resolveAddrs(const uint_least8_t* c64data);
00151
00168 virtual void acceptSidTune(const char* dataFileName, const char* infoFileName,
00169 Buffer_sidtt<const uint_least8_t>& buf, bool isSlashedFileName);
00170
00171 class PetsciiToAscii
00172 {
00173 private:
00174 std::string buffer;
00175 public:
00176 const char* convert(SmartPtr_sidtt<const uint_least8_t>& spPet);
00177 };
00178
00179 private:
00180
00181 #if !defined(SIDTUNE_NO_STDIN_LOADER)
00182 static SidTuneBase* getFromStdIn();
00183 #endif
00184 static SidTuneBase* getFromFiles(const char* name, const char **fileNameExtensions, bool separatorIsSlash);
00185
00187 static SidTuneBase* getFromBuffer(const uint_least8_t* const buffer, uint_least32_t bufferLen);
00188
00189 static void createNewFileName(std::string& destString,
00190 const char* sourceName, const char* sourceExt);
00191
00192 private:
00193 SidTuneBase(const SidTuneBase&);
00194 SidTuneBase& operator=(SidTuneBase&);
00195 };
00196
00197 #endif