00001
00002
00003
00004 #if !defined(__6581_H__)
00005 #define __6581_H__
00006
00007 #include "opstruct.h"
00008 #include "epocglue.h"
00009
00010
00011
00012
00013 class emuEngine;
00014 class sidTune;
00015 class Mixer;
00016 class Envelope;
00017 class Sample;
00018 class C6510;
00019
00020
00025 class sidEmu
00026 {
00027
00028 friend emuEngine;
00029 friend Mixer;
00030 friend Sample;
00031
00032 public:
00033 sbyte waveCalcMute(struct sidOperator* pVoice);
00034 sbyte waveCalcNormal(struct sidOperator* pVoice);
00035 sbyte waveCalcRangeCheck(struct sidOperator* pVoice);
00036
00037 void sidMode00(struct sidOperator* pVoice);
00038 void sidMode10(struct sidOperator* pVoice);
00039 void sidMode20(struct sidOperator* pVoice);
00040 void sidMode30(struct sidOperator* pVoice);
00041 void sidMode40(struct sidOperator* pVoice);
00042 void sidMode50(struct sidOperator* pVoice);
00043 void sidMode60(struct sidOperator* pVoice);
00044 void sidMode70(struct sidOperator* pVoice);
00045 void sidMode80(struct sidOperator* pVoice);
00046 void sidMode80hp(struct sidOperator* pVoice);
00047 void sidModeLock(struct sidOperator* pVoice);
00048 void sidMode14(struct sidOperator* pVoice);
00049 void sidMode34(struct sidOperator* pVoice);
00050 void sidMode54(struct sidOperator* pVoice);
00051 void sidMode74(struct sidOperator* pVoice);
00052
00053 protected:
00054 inline void noiseAdvance(struct sidOperator* pVoice);
00055 inline void noiseAdvanceHp(struct sidOperator* pVoice);
00056
00057 public:
00058 sidEmu(emuEngine* aEmuEngine);
00059 virtual ~sidEmu();
00060
00061 inline void calcValuesPerCall();
00062 void sidEmuSetReplayingSpeed(int clockMode, uword callsPerSec);
00063 inline void sidEmuSet(struct sidOperator* pVoice, uword sidIndex);
00064 inline void waveCalcFilter(struct sidOperator* pVoice);
00065 inline void sidEmuSet2(struct sidOperator* pVoice);
00066 void sidEmuFillBuffer(emuEngine& thisEmu, sidTune& thistune, void* buffer, udword bufferLen);
00067 bool sidEmuFastForwardReplay( int percent );
00068 void sidEmuConfigure(const struct emuConfig& aEmuConfig);
00069
00070
00071 void initWaveformTables(bool isNewSID);
00072 bool sidEmuReset();
00073 void clearSidOperator( struct sidOperator* pVoice );
00074 void sidEmuResetAutoPanning(int autoPanning);
00075 void sidEmuSetVoiceVolume(int voice, uword leftLevel, uword rightLevel, uword total);
00076 uword sidEmuReturnVoiceVolume( int voice );
00077
00078
00079
00080
00081 void sidEmuUpdateReplayingSpeed();
00082
00083
00084 void sidEmuChangeReplayingSpeed();
00085 void sidEmuSetClockSpeed(int clockMode);
00086
00087 public:
00088 struct sidOperator optr1, optr2, optr3;
00089 uword voice4_gainLeft, voice4_gainRight;
00090 udword splitBufferLen;
00091
00092 private:
00093
00094
00095 float filterTable[0x800];
00096 float bandPassParam[0x800];
00097 float filterResTable[16];
00098
00099 ptr2sidVoidFunc sidModeNormalTable[16];
00100 ptr2sidVoidFunc sidModeRingTable[16];
00101
00102 float filterDy, filterResDy;
00103 float C64_fClockSpeed;
00104
00105 uword calls;
00106 uword filterValue;
00107 uword apCount;
00108 uword fastForwardFactor;
00109 uword PCMfreq;
00110 udword sidtuneClockSpeed;
00111 udword PCMsid;
00112 udword PCMsidNoise;
00113 udword C64_clockSpeed;
00114
00115 bool filterEnabled;
00116 bool updateAutoPanning;
00117 bool doAutoPanning;
00118
00119 ubyte filterType;
00120 ubyte filterCurType;
00121
00122 #if defined(DIRECT_FIXPOINT)
00123 cpuLword VALUES, VALUESadd, VALUESorg;
00124 #else
00125 uword VALUES, VALUESorg;
00126 udword VALUESadd, VALUEScomma;
00127 #endif
00128
00129 uword toFill;
00130
00131 #if defined(SIDEMU_TIME_COUNT)
00132 udword prevBufferLen;
00133 udword scaledBufferLen;
00134 #endif
00135
00136 uword defaultTimer;
00137 uword timer;
00138
00139 Sample* iTheSampler;
00140
00141
00142 ubyte* triangleTable;
00143 ubyte* sawtoothTable;
00144 ubyte* squareTable;
00145 ubyte* waveform50;
00146
00147 #if defined(LARGE_NOISE_TABLE)
00148 ubyte* noiseTableMSB;
00149 ubyte* noiseTableLSB;
00150 #else
00151 ubyte* noiseTableMSB;
00152 ubyte* noiseTableMID;
00153 ubyte* noiseTableLSB;
00154 #endif
00155
00156 Envelope* iTheEnvelope;
00157 emuEngine* iTheEmuEngine;
00158 C6510* iThe6510;
00159
00160
00161 ubyte* c64mem1;
00162 ubyte* c64mem2;
00163
00164 };
00165
00166
00167 #endif // __6581_H__