00001
00002
00003
00004
00005 #ifndef __SIDTUNE_H
00006 #define __SIDTUNE_H
00007
00008 #include "epocglue.h"
00009
00010 #if !defined (__EPOC32__) && !defined (__SYMBIAN32__)
00011 #include <fstream.h>
00012 #endif
00013
00014 #include "mytypes.h"
00015
00016 static const int classMaxSongs = 256;
00017 static const int infoStringNum = 5;
00018 static const int infoStringLen = 80+1;
00019
00020 static const int SIDTUNE_SPEED_CIA_1A = 0;
00021 static const int SIDTUNE_SPEED_VBI_PAL = 50;
00022 static const int SIDTUNE_SPEED_VBI_NTSC = 60;
00023
00024 static const int SIDTUNE_CLOCK_PAL = 0;
00025 static const int SIDTUNE_CLOCK_NTSC = 1;
00026
00027
00028
00029 struct sidTuneInfo
00030 {
00031
00032
00033
00034
00035
00036 const char* formatString;
00037 const char* speedString;
00038 uword loadAddr;
00039 uword initAddr;
00040 uword playAddr;
00041 uword startSong;
00042 uword songs;
00043
00044
00045
00046 uword irqAddr;
00047
00048
00049 uword currentSong;
00050 ubyte songSpeed;
00051 ubyte clockSpeed;
00052 bool musPlayer;
00053 uword lengthInSeconds;
00054
00055
00056
00057 ubyte numberOfInfoStrings;
00058 char* infoString[infoStringNum];
00059 char* nameString;
00060 char* authorString;
00061 char* copyrightString;
00062
00063 uword numberOfCommentStrings;
00064 char ** commentString;
00065
00066 udword dataFileLen;
00067 udword c64dataLen;
00068 char* dataFileName;
00069 char* infoFileName;
00070
00071 const char* statusString;
00072 };
00073
00074
00075 class emuEngine;
00076
00077
00078 class sidTune
00079 {
00080
00081 public:
00082
00083
00084
00085
00086
00087 IMPORT_C sidTune(const char* sidTuneFileName);
00088
00089
00090
00091
00092
00093
00094
00095
00096 sidTune(const char* sidTuneFileName, const char **fileNameExt);
00097
00098
00099
00100 sidTune(ubyte* oneFileFormatSidtune, udword sidtuneLength);
00101
00102 virtual ~sidTune();
00103
00104
00105
00106
00107 bool open(const char* sidTuneFileName);
00108 bool load(ubyte* oneFileFormatSidtune, udword sidtuneLength);
00109
00110 IMPORT_C void getInfo( struct sidTuneInfo& );
00111
00112 virtual bool setInfo( struct sidTuneInfo& );
00113
00114 ubyte getSongSpeed() { return info.songSpeed; }
00115 ubyte returnSongSpeed() { return getSongSpeed(); }
00116
00117 uword getPlayAddr() { return info.playAddr; }
00118 uword returnPlayAddr() { return getPlayAddr(); }
00119
00120
00121
00122
00123
00124
00125
00126
00127 friend bool sidEmuInitializeSongOld(emuEngine &, sidTune &, uword songNum);
00128
00129
00130
00131
00132 operator bool() { return status; }
00133 bool getStatus() { return status; }
00134 bool returnStatus() { return getStatus(); }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 bool saveC64dataFile( const char* destFileName, bool overWriteFlag = false );
00146 bool saveSIDfile( const char* destFileName, bool overWriteFlag = false );
00147 bool savePSIDfile( const char* destFileName, bool overWriteFlag = false );
00148 bool saveSID2file( const char* destFileName, bool overWriteFlag = false );
00149
00150
00151 public:
00152
00153 bool status;
00154 sidTuneInfo info;
00155
00156 protected:
00157
00158 ubyte songSpeed[classMaxSongs];
00159 uword songLength[classMaxSongs];
00160
00161
00162 char infoString[infoStringNum][infoStringLen];
00163
00164 ubyte fillUpWidth;
00165
00166 bool isCached;
00167 ubyte* cachePtr;
00168 udword cacheLen;
00169
00170
00171
00172 ubyte* fileBuf;
00173 ubyte* fileBuf2;
00174
00175 udword fileOffset;
00176
00177
00178 const char * const * fileNameExtensions;
00179
00180
00181
00182
00183 void convertOldStyleSpeedToTables(udword oldStyleSpeed);
00184
00185
00186 bool placeSidTuneInC64mem( ubyte* c64buf );
00187
00188 udword loadFile(const char* fileName, ubyte** bufferRef);
00189
00190
00191
00192 bool cacheRawData( void* sourceBuffer, udword sourceBufLen );
00193 bool getCachedRawData( void* destBuffer, udword destBufLen );
00194
00195
00196
00197 virtual bool PSID_fileSupport(void* buffer, udword bufLen);
00198
00199
00200 virtual bool MUS_fileSupport(void* buffer, udword bufLen);
00201 virtual void MUS_installPlayer(ubyte *c64buf);
00202
00203 virtual bool INFO_fileSupport(void* dataBuffer, udword dataBufLen,
00204 void* infoBuffer, udword infoBufLen);
00205
00206 virtual bool SID_fileSupport(void* dataBuffer, udword dataBufLen,
00207 void* sidBuffer, udword sidBufLen);
00208
00209
00210
00211
00212
00213
00214 private:
00215
00216
00217
00218 void safeConstructor();
00219 void safeDestructor();
00220 #if !defined(__POWERPC__)
00221 void stdinConstructor();
00222 #endif
00223 void filesConstructor( const char* );
00224
00225 uword selectSong(uword selectedSong);
00226 void setIRQaddress(uword address);
00227
00228 void deleteFileBuffers();
00229
00230 bool getSidtuneFromFileBuffer(ubyte* buffer, udword bufferLen);
00231
00232
00233 void acceptSidTune(const char* dataFileName, const char* infoFileName,
00234 ubyte* dataFileBuf, udword dataLen );
00235 bool createNewFileName( char** destStringPtr,
00236 const char* sourceName, const char* sourceExt);
00237 };
00238
00239
00240 #endif // __SIDTUNE_H