-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 177f931
Showing
338 changed files
with
44,300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
#include "in_nsf.h" | ||
|
||
using namespace xgm; | ||
|
||
static In_Module mod; | ||
|
||
/** プラグイン本体 */ | ||
static WA2NSF *pPlugin; | ||
static HINSTANCE hPlugin; | ||
|
||
static NSF *sdat; | ||
static NSFplug_UI_DLL *ui; | ||
static NSFplug_Model npm; | ||
|
||
static char DllPath[MAX_PATH]; | ||
static HANDLE hDbgfile; | ||
|
||
BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) | ||
{ | ||
char path[MAX_PATH+16]; | ||
switch (ul_reason_for_call) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
#if defined(_MSC_VER) | ||
#ifdef _DEBUG | ||
hDbgfile = CreateFile("C:\\in_nsf.log", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ; | ||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ) ; | ||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ) ; | ||
_CrtSetReportFile( _CRT_WARN, (HANDLE)hDbgfile ) ; | ||
#endif | ||
#endif | ||
hPlugin = (HINSTANCE)hModule; | ||
|
||
// DLLパスの取得 | ||
GetModuleFileName(hPlugin, DllPath, MAX_PATH); | ||
strrchr(DllPath,'\\')[1] = '\0'; | ||
|
||
// プレイヤー作成 | ||
npm.pl = new NSFPlayer(); | ||
npm.sdat = new NSF(); | ||
npm.cf = new NSFPlayerConfig(); | ||
|
||
// Winamp版の設定を拡張 | ||
npm.cf->CreateValue("WRITE_TAGINFO", 0); | ||
npm.cf->CreateValue("READ_TAGINFO", 0); | ||
npm.cf->CreateValue("UPDATE_PLAYLIST", 0); | ||
npm.cf->CreateValue("MASK_INIT", 1); | ||
npm.cf->CreateValue("INFO_DELAY", 250); | ||
npm.cf->CreateValue("INFO_FREQ", 20); | ||
npm.cf->CreateValue("GRAPHIC_MODE", 1); | ||
npm.cf->CreateValue("FREQ_MODE", 1); | ||
npm.cf->CreateValue("LAST_PRESET", "Default"); | ||
npm.cf->CreateValue("INI_FILE", ""); | ||
|
||
// コンフィグレーションのロード | ||
strcpy(path,DllPath); | ||
strcat(path,"in_yansf.ini"); | ||
npm.cf->Load(path,"NSFplug"); | ||
(*(npm.cf))["INI_FILE"] = path; | ||
|
||
if((*(npm.cf))["MASK_INIT"]) (*(npm.cf))["MASK"] = 0; | ||
|
||
// GUIのロード | ||
strcpy(path,DllPath); | ||
strcat(path,"nsfplug_ui.dll"); | ||
ui = new NSFplug_UI_DLL(path,&npm,0); | ||
|
||
pPlugin = new WA2NSF(npm.pl,npm.cf,npm.sdat); | ||
pPlugin->SetUserInterface(ui); | ||
break; | ||
|
||
case DLL_PROCESS_DETACH: | ||
// コンフィグレーションのセーブ | ||
strcpy(path,DllPath); | ||
strcat(path,"in_yansf.ini"); | ||
npm.cf->Save(path,"NSFplug"); | ||
|
||
delete pPlugin; | ||
delete npm.pl; | ||
delete npm.cf; | ||
delete npm.sdat; | ||
//delete ui; | ||
break; | ||
} | ||
return TRUE; | ||
} | ||
|
||
static void Config(HWND hParent) | ||
{ | ||
pPlugin->Config(hParent); | ||
} | ||
static void About(HWND hParent) | ||
{ | ||
pPlugin->About(hParent); | ||
} | ||
static void Init() | ||
{ | ||
pPlugin->Init(); | ||
} | ||
static void Quit() | ||
{ | ||
pPlugin->Quit(); | ||
} | ||
static void GetFileInfo(char *file, char *title, int *length_in_ms) | ||
{ | ||
pPlugin->GetFileInfo(file, title, length_in_ms); | ||
} | ||
static int InfoBox(char *fn, HWND hParent) | ||
{ | ||
return pPlugin->InfoBox(fn, hParent); | ||
} | ||
static int IsOurFile(char *fn) | ||
{ | ||
return pPlugin->IsOurFile(fn); | ||
} | ||
static int Play(char *fn) | ||
{ | ||
int ret = pPlugin->Play(fn); | ||
if(!ret) ui->StartUpdate(); | ||
return ret; | ||
} | ||
static void Pause() | ||
{ | ||
pPlugin->Pause(); | ||
} | ||
static void UnPause() | ||
{ | ||
pPlugin->UnPause(); | ||
} | ||
static int IsPaused() | ||
{ | ||
return pPlugin->IsPaused(); | ||
} | ||
static void Stop() | ||
{ | ||
ui->StopUpdate(); | ||
pPlugin->Stop(); | ||
} | ||
static int GetLength() | ||
{ | ||
return pPlugin->GetLength(); | ||
} | ||
static int GetOutputTime() | ||
{ | ||
return pPlugin->GetOutputTime(); | ||
} | ||
static void SetOutputTime(int time_in_ms) | ||
{ | ||
pPlugin->SetOutputTime(time_in_ms); | ||
} | ||
static void SetVolume(int volume) | ||
{ | ||
pPlugin->SetVolume(volume); | ||
} | ||
static void SetPan(int pan) | ||
{ | ||
pPlugin->SetPan(pan); | ||
} | ||
static void EQSet(int on, char data[], int preamp) | ||
{ | ||
pPlugin->EQSet(on,data,preamp); | ||
} | ||
|
||
extern "C" __declspec( dllexport ) In_Module *winampGetInModule2() | ||
{ | ||
mod.version = IN_VER; | ||
mod.is_seekable = 1; | ||
mod.UsesOutputPlug = 1; | ||
mod.description = "NSFplug " "("__DATE__" "__TIME__")"; | ||
mod.FileExtensions = "nsf\0NSF file\0"; | ||
mod.Config = Config; | ||
mod.About = About; | ||
mod.Init = Init; | ||
mod.Quit = Quit; | ||
mod.GetFileInfo = GetFileInfo; | ||
mod.InfoBox = InfoBox; | ||
mod.IsOurFile = IsOurFile; | ||
mod.Play = Play; | ||
mod.Pause = Pause; | ||
mod.UnPause = UnPause; | ||
mod.IsPaused = IsPaused; | ||
mod.Stop = Stop; | ||
mod.GetLength = GetLength; | ||
mod.GetOutputTime = GetOutputTime; | ||
mod.SetOutputTime = SetOutputTime; | ||
mod.SetVolume = SetVolume; | ||
mod.SetPan = SetPan; | ||
mod.EQSet = EQSet; | ||
pPlugin->SetModule(&mod); | ||
return &mod; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#ifndef _IN_NSF_H_ | ||
#define _IN_NSF_H_ | ||
#include "xgm.h" | ||
#include "utils/nsf_tag.h" | ||
#include "nsfplug_ui.h" | ||
|
||
class WA2NSF : public WA2InputModuleMSP | ||
{ | ||
protected: | ||
xgm::NSFPlayer *pl; | ||
xgm::NSFPlayerConfig *cf; | ||
xgm::NSF *sdat; | ||
NSFplug_UI *ui; | ||
NSF_TAG *ntag; | ||
|
||
public: | ||
WA2NSF(xgm::NSFPlayer *p, xgm::NSFPlayerConfig *c, xgm::NSF *s) | ||
: pl(p), cf(c), sdat(s), WA2InputModuleMSP(p,c,s) | ||
{ | ||
ntag = new NSF_TAG(s); | ||
} | ||
|
||
virtual ~WA2NSF() | ||
{ | ||
delete ntag; | ||
} | ||
|
||
virtual void SetUserInterface(NSFplug_UI *u) | ||
{ | ||
ui = u; | ||
ui->SetWA2InputModule(this); | ||
} | ||
|
||
virtual int IsOurFile(char *fn) | ||
{ | ||
xgm::NSF nsf; | ||
return nsf.LoadFile(fn); | ||
} | ||
|
||
virtual void GetFileInfo(char *file, char *title, int *length_in_ms) | ||
{ | ||
xgm::NSF nsf; | ||
|
||
nsf.SetDefaults((*cf)["PLAY_TIME"], (*cf)["FADE_TIME"], (*cf)["LOOP_NUM"]); | ||
|
||
if(file==NULL||file[0]=='\0') | ||
{ | ||
strcpy(title,pl->GetTitleString()); | ||
*length_in_ms = pl->GetLength(); | ||
return; | ||
} | ||
else | ||
{ | ||
if(nsf.LoadFile(file)) | ||
{ | ||
strcpy(title,nsf.GetTitleString((*cf)["TITLE_FORMAT"])); | ||
*length_in_ms = nsf.GetLength(); | ||
} | ||
else | ||
strcpy(title,"Not a NSF file."); | ||
} | ||
} | ||
|
||
virtual int Play(char *fn) | ||
{ | ||
sdat->SetDefaults((*cf)["PLAY_TIME"], (*cf)["FADE_TIME"], (*cf)["LOOP_NUM"]); | ||
|
||
if(WA2InputModuleMSP::Play(fn)) | ||
return 1; | ||
|
||
ntag->Sync(); | ||
|
||
// ローカルタグもtaginfo.tagも無ければ生成する | ||
if((int)(*cf)["WRITE_TAGINFO"]&&!ntag->IsExistSection(true)&&!ntag->IsExistSection(false)) | ||
ntag->CreateTag((*cf)["TITLE_FORMAT"]); | ||
|
||
if(!sdat->playlist_mode&&(int)(*cf)["READ_TAGINFO"]) | ||
ntag->ReadTagItem(sdat->song); | ||
|
||
if(ui) ui->SetInfoData(sdat); | ||
|
||
return 0; | ||
} | ||
|
||
virtual void Config(HWND hParent) | ||
{ | ||
if(ui) { | ||
ui->SetPlayerWindow(pMod->hMainWindow); | ||
ui->OpenDialog(NSFplug_UI::DLG_CONFIG); | ||
} | ||
} | ||
|
||
virtual int InfoBox(char *fn, HWND hParent) | ||
{ | ||
if(ui) { | ||
ui->SetPlayerWindow(pMod->hMainWindow); | ||
ui->SetInfoData(fn); | ||
ui->OpenDialog(NSFplug_UI::DLG_INFO); | ||
} | ||
return 1; | ||
} | ||
|
||
virtual void PreAutoStop() | ||
{ | ||
if((int)(*cf)["UPDATE_PLAYLIST"]&&pl->IsDetected()) | ||
{ | ||
if(sdat->playlist_mode) | ||
SendMessage(pMod->hMainWindow,WM_WA_IPC,(WPARAM)sdat->GetPlaylistString((*cf)["TITLE_FORMAT"],true),IPC_CHANGECURRENTFILE); | ||
else if((int)(*cf)["WRITE_TAGINFO"]&&ntag->IsWriteEnable()) | ||
ntag->UpdateTagItem(sdat->song,(*cf)["TITLE_FORMAT"],(*cf)["LOOP_NUM"]); | ||
} | ||
WA2InputModuleMSP::PreAutoStop(); | ||
} | ||
|
||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.