mirror of https://github.com/PCSX2/pcsx2.git
SPU2null reformat
This commit is contained in:
parent
67e7d63f0f
commit
e3a2ad03bc
|
@ -23,44 +23,44 @@ using namespace std;
|
|||
extern string s_strIniPath;
|
||||
PluginConf Ini;
|
||||
|
||||
EXPORT_C_(void) SPU2configure()
|
||||
EXPORT_C_(void)
|
||||
SPU2configure()
|
||||
{
|
||||
LoadConfig();
|
||||
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
|
||||
SaveConfig();
|
||||
LoadConfig();
|
||||
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2about()
|
||||
EXPORT_C_(void)
|
||||
SPU2about()
|
||||
{
|
||||
//SysMessage("%s %d.%d", libraryName, version, build);
|
||||
SysMessage("SPU2null: A simple null plugin.");
|
||||
//SysMessage("%s %d.%d", libraryName, version, build);
|
||||
SysMessage("SPU2null: A simple null plugin.");
|
||||
}
|
||||
|
||||
void LoadConfig()
|
||||
{
|
||||
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
|
||||
|
||||
if (!Ini.Open(iniFile, READ_FILE))
|
||||
{
|
||||
printf("failed to open %s\n", iniFile.c_str());
|
||||
SaveConfig();//save and return
|
||||
return;
|
||||
}
|
||||
if (!Ini.Open(iniFile, READ_FILE)) {
|
||||
printf("failed to open %s\n", iniFile.c_str());
|
||||
SaveConfig(); //save and return
|
||||
return;
|
||||
}
|
||||
|
||||
conf.Log = Ini.ReadInt("logging", 0);
|
||||
Ini.Close();
|
||||
conf.Log = Ini.ReadInt("logging", 0);
|
||||
Ini.Close();
|
||||
}
|
||||
|
||||
void SaveConfig()
|
||||
{
|
||||
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
|
||||
|
||||
if (!Ini.Open(iniFile, WRITE_FILE))
|
||||
{
|
||||
printf("failed to open %s\n", iniFile.c_str());
|
||||
return;
|
||||
}
|
||||
if (!Ini.Open(iniFile, WRITE_FILE)) {
|
||||
printf("failed to open %s\n", iniFile.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Ini.WriteInt("logging", conf.Log);
|
||||
Ini.Close();
|
||||
Ini.WriteInt("logging", conf.Log);
|
||||
Ini.Close();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,8 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#define SPU2defs
|
||||
#include "PS2Edefs.h"
|
||||
}
|
||||
|
@ -39,114 +38,115 @@ extern "C"
|
|||
#ifdef _MSC_VER
|
||||
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
||||
#else
|
||||
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
|
||||
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
|
||||
#endif
|
||||
|
||||
extern FILE *spu2Log;
|
||||
extern FILE* spu2Log;
|
||||
#define SPU2_LOG __Log //debug mode
|
||||
|
||||
extern const u8 version;
|
||||
extern const u8 revision;
|
||||
extern const u8 build;
|
||||
extern const u32 minor;
|
||||
extern char *libraryName;
|
||||
extern char* libraryName;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s32 Log;
|
||||
s32 Log;
|
||||
} Config;
|
||||
|
||||
extern Config conf;
|
||||
|
||||
void __Log(char *fmt, ...);
|
||||
void __Log(char* fmt, ...);
|
||||
void SaveConfig();
|
||||
void LoadConfig();
|
||||
void SysMessage(char *fmt, ...);
|
||||
void SysMessage(char* fmt, ...);
|
||||
|
||||
////////////////////
|
||||
// SPU2 Registers //
|
||||
////////////////////
|
||||
#define REG_VP_VOLL 0x0000
|
||||
#define REG_VP_VOLR 0x0002
|
||||
#define REG_VP_PITCH 0x0004
|
||||
#define REG_VP_ADSR1 0x0006
|
||||
#define REG_VP_ADSR2 0x0008
|
||||
#define REG_VP_ENVX 0x000A
|
||||
#define REG_VP_VOLXL 0x000C
|
||||
#define REG_VP_VOLXR 0x000E
|
||||
#define REG_C0_FMOD1 0x0180
|
||||
#define REG_C0_FMOD2 0x0182
|
||||
#define REG_C1_FMOD1 0x0580
|
||||
#define REG_C1_FMOD2 0x0582
|
||||
#define REG_S_NON 0x0184
|
||||
#define REG_S_VMIXL 0x0188
|
||||
#define REG_S_VMIXEL 0x018C
|
||||
#define REG_S_VMIXR 0x0190
|
||||
#define REG_S_VMIXER 0x0194
|
||||
#define REG_C0_MMIX 0x0198
|
||||
#define REG_C1_MMIX 0x0598
|
||||
#define REG_C0_CTRL 0x019A
|
||||
#define REG_C0_IRQA_HI 0x019C
|
||||
#define REG_C0_IRQA_LO 0x019D
|
||||
#define REG_C1_IRQA_HI 0x059C
|
||||
#define REG_C1_IRQA_LO 0x059D
|
||||
#define REG_C0_SPUON1 0x1A0
|
||||
#define REG_C0_SPUON2 0x1A2
|
||||
#define REG_C1_SPUON1 0x5A0
|
||||
#define REG_C1_SPUON2 0x5A2
|
||||
#define REG_C0_SPUOFF1 0x1A4
|
||||
#define REG_C0_SPUOFF2 0x1A6
|
||||
#define REG_C1_SPUOFF1 0x5A4
|
||||
#define REG_C1_SPUOFF2 0x5A6
|
||||
#define REG_VP_VOLL 0x0000
|
||||
#define REG_VP_VOLR 0x0002
|
||||
#define REG_VP_PITCH 0x0004
|
||||
#define REG_VP_ADSR1 0x0006
|
||||
#define REG_VP_ADSR2 0x0008
|
||||
#define REG_VP_ENVX 0x000A
|
||||
#define REG_VP_VOLXL 0x000C
|
||||
#define REG_VP_VOLXR 0x000E
|
||||
#define REG_C0_FMOD1 0x0180
|
||||
#define REG_C0_FMOD2 0x0182
|
||||
#define REG_C1_FMOD1 0x0580
|
||||
#define REG_C1_FMOD2 0x0582
|
||||
#define REG_S_NON 0x0184
|
||||
#define REG_S_VMIXL 0x0188
|
||||
#define REG_S_VMIXEL 0x018C
|
||||
#define REG_S_VMIXR 0x0190
|
||||
#define REG_S_VMIXER 0x0194
|
||||
#define REG_C0_MMIX 0x0198
|
||||
#define REG_C1_MMIX 0x0598
|
||||
#define REG_C0_CTRL 0x019A
|
||||
#define REG_C0_IRQA_HI 0x019C
|
||||
#define REG_C0_IRQA_LO 0x019D
|
||||
#define REG_C1_IRQA_HI 0x059C
|
||||
#define REG_C1_IRQA_LO 0x059D
|
||||
#define REG_C0_SPUON1 0x1A0
|
||||
#define REG_C0_SPUON2 0x1A2
|
||||
#define REG_C1_SPUON1 0x5A0
|
||||
#define REG_C1_SPUON2 0x5A2
|
||||
#define REG_C0_SPUOFF1 0x1A4
|
||||
#define REG_C0_SPUOFF2 0x1A6
|
||||
#define REG_C1_SPUOFF1 0x5A4
|
||||
#define REG_C1_SPUOFF2 0x5A6
|
||||
#define REG_C0_SPUADDR_HI 0x01A8
|
||||
#define REG_C0_SPUADDR_LO 0x01AA
|
||||
#define REG_C1_SPUADDR_HI 0x05A8
|
||||
#define REG_C1_SPUADDR_LO 0x05AA
|
||||
#define REG_C0_SPUDATA 0x01AC
|
||||
#define REG_C1_SPUDATA 0x05AC
|
||||
#define REG_C0_DMACTRL 0x01AE
|
||||
#define REG_C1_DMACTRL 0x05AE
|
||||
#define REG_C0_ADMAS 0x01B0
|
||||
#define REG_VA_SSA 0x01C0
|
||||
#define REG_VA_LSAX 0x01C4
|
||||
#define REG_VA_NAX 0x01C8
|
||||
#define REG_A_ESA 0x02E0
|
||||
#define REG_A_EEA 0x033C
|
||||
#define REG_C0_END1 0x0340
|
||||
#define REG_C0_END2 0x0342
|
||||
#define REG_C1_END1 0x0740
|
||||
#define REG_C1_END2 0x0742
|
||||
#define REG_C0_SPUSTAT 0x0344 //not sure!
|
||||
#define REG_C1_CTRL 0x059A
|
||||
#define REG_C1_ADMAS 0x05B0
|
||||
#define REG_C1_SPUSTAT 0x0744 //not sure!
|
||||
#define REG_P_MVOLL 0x0760
|
||||
#define REG_P_MVOLR 0x0762
|
||||
#define REG_P_EVOLL 0x0764
|
||||
#define REG_P_EVOLR 0x0766
|
||||
#define REG_P_AVOLL 0x0768
|
||||
#define REG_P_AVOLR 0x076A
|
||||
#define REG_P_BVOLL 0x076C
|
||||
#define REG_P_BVOLR 0x076E
|
||||
#define REG_P_MVOLXL 0x0770
|
||||
#define REG_P_MVOLXR 0x0772
|
||||
#define SPDIF_OUT 0x07C0
|
||||
#define REG_IRQINFO 0x07C2
|
||||
#define SPDIF_MODE 0x07C6
|
||||
#define SPDIF_MEDIA 0x07C8
|
||||
#define REG_C0_SPUDATA 0x01AC
|
||||
#define REG_C1_SPUDATA 0x05AC
|
||||
#define REG_C0_DMACTRL 0x01AE
|
||||
#define REG_C1_DMACTRL 0x05AE
|
||||
#define REG_C0_ADMAS 0x01B0
|
||||
#define REG_VA_SSA 0x01C0
|
||||
#define REG_VA_LSAX 0x01C4
|
||||
#define REG_VA_NAX 0x01C8
|
||||
#define REG_A_ESA 0x02E0
|
||||
#define REG_A_EEA 0x033C
|
||||
#define REG_C0_END1 0x0340
|
||||
#define REG_C0_END2 0x0342
|
||||
#define REG_C1_END1 0x0740
|
||||
#define REG_C1_END2 0x0742
|
||||
#define REG_C0_SPUSTAT 0x0344 //not sure!
|
||||
#define REG_C1_CTRL 0x059A
|
||||
#define REG_C1_ADMAS 0x05B0
|
||||
#define REG_C1_SPUSTAT 0x0744 //not sure!
|
||||
#define REG_P_MVOLL 0x0760
|
||||
#define REG_P_MVOLR 0x0762
|
||||
#define REG_P_EVOLL 0x0764
|
||||
#define REG_P_EVOLR 0x0766
|
||||
#define REG_P_AVOLL 0x0768
|
||||
#define REG_P_AVOLR 0x076A
|
||||
#define REG_P_BVOLL 0x076C
|
||||
#define REG_P_BVOLR 0x076E
|
||||
#define REG_P_MVOLXL 0x0770
|
||||
#define REG_P_MVOLXR 0x0772
|
||||
#define SPDIF_OUT 0x07C0
|
||||
#define REG_IRQINFO 0x07C2
|
||||
#define SPDIF_MODE 0x07C6
|
||||
#define SPDIF_MEDIA 0x07C8
|
||||
|
||||
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff])
|
||||
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff])
|
||||
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem)&0xffff])
|
||||
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem)&0xffff])
|
||||
//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff])
|
||||
//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff])
|
||||
|
||||
#define IRQINFO spu2Ru16(REG_IRQINFO)
|
||||
|
||||
#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo))
|
||||
#define SPU2_SET32BIT(value, lo, hi) { \
|
||||
spu2Ru16(hi) = ((value)>>16)&0x3f; \
|
||||
spu2Ru16(lo) = (value)&0xffff; \
|
||||
} \
|
||||
#define SPU2_GET32BIT(lo, hi) (((u32)(spu2Ru16(hi) & 0x3f) << 16) | (u32)spu2Ru16(lo))
|
||||
#define SPU2_SET32BIT(value, lo, hi) \
|
||||
{ \
|
||||
spu2Ru16(hi) = ((value) >> 16) & 0x3f; \
|
||||
spu2Ru16(lo) = (value)&0xffff; \
|
||||
}
|
||||
|
||||
#define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI)
|
||||
#define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI)
|
||||
|
@ -157,20 +157,20 @@ void SysMessage(char *fmt, ...);
|
|||
#define C0_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C0_IRQA_LO, REG_C0_IRQA_HI)
|
||||
#define C1_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C1_IRQA_LO, REG_C1_IRQA_HI)
|
||||
|
||||
#define SPU_NUMBER_VOICES 48
|
||||
#define SPU_NUMBER_VOICES 48
|
||||
|
||||
struct SPU_CONTROL_
|
||||
{
|
||||
u16 spuon : 1;
|
||||
u16 spuUnmute : 1;
|
||||
u16 noiseFreq : 6;
|
||||
u16 reverb : 1;
|
||||
u16 irq : 1;
|
||||
u16 dma : 2; // 1 - no dma, 2 - write, 3 - read
|
||||
u16 extr : 1; // external reverb
|
||||
u16 cdreverb : 1;
|
||||
u16 extAudio : 1;
|
||||
u16 extCd : 1;
|
||||
u16 spuon : 1;
|
||||
u16 spuUnmute : 1;
|
||||
u16 noiseFreq : 6;
|
||||
u16 reverb : 1;
|
||||
u16 irq : 1;
|
||||
u16 dma : 2; // 1 - no dma, 2 - write, 3 - read
|
||||
u16 extr : 1; // external reverb
|
||||
u16 cdreverb : 1;
|
||||
u16 extAudio : 1;
|
||||
u16 extCd : 1;
|
||||
};
|
||||
|
||||
// the layout of each voice in wSpuRegs
|
||||
|
@ -178,115 +178,117 @@ struct _SPU_VOICE
|
|||
{
|
||||
union
|
||||
{
|
||||
struct {
|
||||
u16 Vol : 14;
|
||||
u16 Inverted : 1;
|
||||
u16 Sweep0 : 1;
|
||||
struct
|
||||
{
|
||||
u16 Vol : 14;
|
||||
u16 Inverted : 1;
|
||||
u16 Sweep0 : 1;
|
||||
} vol;
|
||||
struct {
|
||||
u16 Vol : 7;
|
||||
u16 res1 : 5;
|
||||
u16 Inverted : 1;
|
||||
u16 Decrease : 1; // if 0, increase
|
||||
u16 ExpSlope : 1; // if 0, linear slope
|
||||
u16 Sweep1 : 1; // always one
|
||||
} sweep;
|
||||
u16 word;
|
||||
} left, right;
|
||||
struct
|
||||
{
|
||||
u16 Vol : 7;
|
||||
u16 res1 : 5;
|
||||
u16 Inverted : 1;
|
||||
u16 Decrease : 1; // if 0, increase
|
||||
u16 ExpSlope : 1; // if 0, linear slope
|
||||
u16 Sweep1 : 1; // always one
|
||||
} sweep;
|
||||
u16 word;
|
||||
} left, right;
|
||||
|
||||
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
|
||||
u16 res0 : 2;
|
||||
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
|
||||
u16 res0 : 2;
|
||||
|
||||
u16 SustainLvl : 4;
|
||||
u16 DecayRate : 4;
|
||||
u16 AttackRate : 7;
|
||||
u16 AttackExp : 1; // if 0, linear
|
||||
u16 SustainLvl : 4;
|
||||
u16 DecayRate : 4;
|
||||
u16 AttackRate : 7;
|
||||
u16 AttackExp : 1; // if 0, linear
|
||||
|
||||
u16 ReleaseRate : 5;
|
||||
u16 ReleaseExp : 1; // if 0, linear
|
||||
u16 SustainRate : 7;
|
||||
u16 res1 : 1;
|
||||
u16 SustainDec : 1; // if 0, inc
|
||||
u16 SustainExp : 1; // if 0, linear
|
||||
u16 ReleaseRate : 5;
|
||||
u16 ReleaseExp : 1; // if 0, linear
|
||||
u16 SustainRate : 7;
|
||||
u16 res1 : 1;
|
||||
u16 SustainDec : 1; // if 0, inc
|
||||
u16 SustainExp : 1; // if 0, linear
|
||||
|
||||
u16 AdsrVol;
|
||||
u16 Address; // add / 8
|
||||
u16 RepeatAddr; // gets reset when sample starts
|
||||
u16 AdsrVol;
|
||||
u16 Address; // add / 8
|
||||
u16 RepeatAddr; // gets reset when sample starts
|
||||
};
|
||||
|
||||
// ADSR INFOS PER CHANNEL
|
||||
struct ADSRInfoEx
|
||||
{
|
||||
s32 State;
|
||||
s32 AttackModeExp;
|
||||
s32 AttackRate;
|
||||
s32 DecayRate;
|
||||
s32 SustainLevel;
|
||||
s32 SustainModeExp;
|
||||
s32 SustainIncrease;
|
||||
s32 SustainRate;
|
||||
s32 ReleaseModeExp;
|
||||
s32 ReleaseRate;
|
||||
s32 EnvelopeVol;
|
||||
s32 lVolume;
|
||||
s32 State;
|
||||
s32 AttackModeExp;
|
||||
s32 AttackRate;
|
||||
s32 DecayRate;
|
||||
s32 SustainLevel;
|
||||
s32 SustainModeExp;
|
||||
s32 SustainIncrease;
|
||||
s32 SustainRate;
|
||||
s32 ReleaseModeExp;
|
||||
s32 ReleaseRate;
|
||||
s32 EnvelopeVol;
|
||||
s32 lVolume;
|
||||
};
|
||||
|
||||
#define NSSIZE 48 // ~ 1 ms of data
|
||||
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
|
||||
#define NSSIZE 48 // ~ 1 ms of data
|
||||
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
|
||||
#define NSPACKETS 4
|
||||
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*))
|
||||
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void*))
|
||||
|
||||
struct VOICE_PROCESSED
|
||||
{
|
||||
VOICE_PROCESSED()
|
||||
{
|
||||
memset(this, 0, sizeof(VOICE_PROCESSED));
|
||||
}
|
||||
~VOICE_PROCESSED()
|
||||
{
|
||||
}
|
||||
VOICE_PROCESSED()
|
||||
{
|
||||
memset(this, 0, sizeof(VOICE_PROCESSED));
|
||||
}
|
||||
~VOICE_PROCESSED()
|
||||
{
|
||||
}
|
||||
|
||||
void SetVolume(int right);
|
||||
void StartSound();
|
||||
void VoiceChangeFrequency();
|
||||
void FModChangeFrequency(int ns);
|
||||
void Stop();
|
||||
void SetVolume(int right);
|
||||
void StartSound();
|
||||
void VoiceChangeFrequency();
|
||||
void FModChangeFrequency(int ns);
|
||||
void Stop();
|
||||
|
||||
SPU_CONTROL_* GetCtrl();
|
||||
SPU_CONTROL_* GetCtrl();
|
||||
|
||||
// start save state
|
||||
// start save state
|
||||
|
||||
s32 iSBPos; // mixing stuff
|
||||
s32 spos;
|
||||
s32 sinc;
|
||||
s32 iSBPos; // mixing stuff
|
||||
s32 spos;
|
||||
s32 sinc;
|
||||
|
||||
s32 iActFreq; // current psx pitch
|
||||
s32 iUsedFreq; // current pc pitch
|
||||
s32 iActFreq; // current psx pitch
|
||||
s32 iUsedFreq; // current pc pitch
|
||||
|
||||
s32 iStartAddr, iLoopAddr, iNextAddr;
|
||||
s32 iStartAddr, iLoopAddr, iNextAddr;
|
||||
|
||||
ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start)
|
||||
bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged;
|
||||
s32 memoffset; // if first core, 0, if second, 0x400
|
||||
ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start)
|
||||
bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged;
|
||||
s32 memoffset; // if first core, 0, if second, 0x400
|
||||
|
||||
// end save state
|
||||
// end save state
|
||||
|
||||
///////////////////
|
||||
// Sound Buffers //
|
||||
///////////////////
|
||||
u8* pStart; // start and end addresses
|
||||
u8* pLoop, *pCurr;
|
||||
///////////////////
|
||||
// Sound Buffers //
|
||||
///////////////////
|
||||
u8* pStart; // start and end addresses
|
||||
u8 *pLoop, *pCurr;
|
||||
|
||||
_SPU_VOICE* pvoice;
|
||||
_SPU_VOICE* pvoice;
|
||||
};
|
||||
|
||||
struct ADMA
|
||||
{
|
||||
u16 * MemAddr;
|
||||
s32 IntPointer;
|
||||
s32 Index;
|
||||
s32 AmountLeft;
|
||||
s32 Enabled;
|
||||
u16* MemAddr;
|
||||
s32 IntPointer;
|
||||
s32 Index;
|
||||
s32 AmountLeft;
|
||||
s32 Enabled;
|
||||
};
|
||||
|
||||
#endif /* __SPU2_H__ */
|
||||
|
|
|
@ -21,46 +21,45 @@ extern HINSTANCE hInst;
|
|||
void SaveConfig()
|
||||
{
|
||||
|
||||
Config *Conf1 = &conf;
|
||||
char *szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
Config* Conf1 = &conf;
|
||||
char* szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
|
||||
if(!szTemp) return;
|
||||
strcpy(szTemp, "\\inis\\spu2null.ini");
|
||||
sprintf(szValue,"%u",Conf1->Log);
|
||||
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
|
||||
if (!szTemp)
|
||||
return;
|
||||
strcpy(szTemp, "\\inis\\spu2null.ini");
|
||||
sprintf(szValue, "%u", Conf1->Log);
|
||||
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
|
||||
}
|
||||
|
||||
void LoadConfig() {
|
||||
FILE *fp;
|
||||
void LoadConfig()
|
||||
{
|
||||
FILE* fp;
|
||||
|
||||
|
||||
Config *Conf1 = &conf;
|
||||
char *szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
Config* Conf1 = &conf;
|
||||
char* szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
|
||||
if(!szTemp) return ;
|
||||
strcpy(szTemp, "\\inis\\spu2null.ini");
|
||||
fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists
|
||||
if (!fp)
|
||||
{
|
||||
CreateDirectory("inis",NULL);
|
||||
if (!szTemp)
|
||||
return;
|
||||
strcpy(szTemp, "\\inis\\spu2null.ini");
|
||||
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
|
||||
if (!fp) {
|
||||
CreateDirectory("inis", NULL);
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
conf.Log = 0;//default value
|
||||
SaveConfig();//save and return
|
||||
return ;
|
||||
}
|
||||
fclose(fp);
|
||||
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
||||
Conf1->Log = strtoul(szValue, NULL, 10);
|
||||
return ;
|
||||
|
||||
conf.Log = 0; //default value
|
||||
SaveConfig(); //save and return
|
||||
return;
|
||||
}
|
||||
fclose(fp);
|
||||
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
||||
Conf1->Log = strtoul(szValue, NULL, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,75 +22,81 @@
|
|||
|
||||
HINSTANCE hInst;
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
void SysMessage(char* fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_end(list);
|
||||
MessageBox(0, tmp, "SPU2NULL Msg", 0);
|
||||
va_start(list, fmt);
|
||||
vsprintf(tmp, fmt, list);
|
||||
va_end(list);
|
||||
MessageBox(0, tmp, "SPU2NULL Msg", 0);
|
||||
}
|
||||
|
||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
LoadConfig();
|
||||
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
|
||||
return TRUE;
|
||||
switch (uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
LoadConfig();
|
||||
if (conf.Log)
|
||||
CheckDlgButton(hW, IDC_LOGGING, TRUE);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDCANCEL:
|
||||
EndDialog(hW, TRUE);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
if (IsDlgButtonChecked(hW, IDC_LOGGING))
|
||||
conf.Log = 1;
|
||||
else conf.Log = 0;
|
||||
SaveConfig();
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDCANCEL:
|
||||
EndDialog(hW, TRUE);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
if (IsDlgButtonChecked(hW, IDC_LOGGING))
|
||||
conf.Log = 1;
|
||||
else
|
||||
conf.Log = 0;
|
||||
SaveConfig();
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CALLBACK SPU2configure() {
|
||||
void CALLBACK SPU2configure()
|
||||
{
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)ConfigureDlgProc);
|
||||
|
||||
}
|
||||
|
||||
void CALLBACK SPU2about() {
|
||||
void CALLBACK SPU2about()
|
||||
{
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_ABOUT),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)AboutDlgProc);
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved) {
|
||||
hInst = (HINSTANCE)hModule;
|
||||
return TRUE; // very quick :)
|
||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
hInst = (HINSTANCE)hModule;
|
||||
return TRUE; // very quick :)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue