diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1e9380c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+src/objs_d
+src/objs
+src/stderr.txt
+src/stdout.txt
+
+src/mucom88
+src/mucom88.exe
+src/mucom88_d
+src/mucom88_d.exe
+src/osdep_test
+src/osdep_test.exe
+src/mod_test
+src/mod_test.exe
+src/miniplay
+src/miniplay.exe
+
+xcode/miniosx.xcodeproj/xcuserdata
+xcode/DerivedData
+xcode/miniosx.xcodeproj/project.xcworkspace/xcuserdata
+
+src/mucom88.vcxproj.user
+src/.vs/
+src/Debug
+
diff --git a/muplug_test/dllmain.cpp b/muplug_test/dllmain.cpp
new file mode 100644
index 0000000..d7b3a68
--- /dev/null
+++ b/muplug_test/dllmain.cpp
@@ -0,0 +1,45 @@
+// dllmain.cpp : DLL アプリケーションのエントリ ポイントを定義します。
+#include "stdafx.h"
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
+//--------------------------------------------------
+// プラグイン機能コールバック
+//--------------------------------------------------
+
+static int noticeCallback(void *instance, int cmd, void *p1, void *p2)
+{
+ Mucom88Plugin *plg = (Mucom88Plugin *)instance;
+ printf( "#Notice %d.\n",cmd );
+ return 0;
+}
+
+
+//--------------------------------------------------
+// プラグイン初期化
+//--------------------------------------------------
+extern "C" __declspec(dllexport) int InitalizePlugin(Mucom88Plugin *plugin, int bootopt )
+{
+ plugin->info = "MUCOM88 TEST PLUGIN"; // プラグイン情報テキスト
+ plugin->type = MUCOM88IF_TYPE_SILENT; // プラグインタイプを設定(MUCOM88IF_TYPE_*)
+ plugin->if_notice = noticeCallback; // 通知用コールバックを登録する
+
+ printf( "Welcome! plugin!\n" );
+
+ return 0;
+}
+
diff --git a/muplug_test/muplug_test.cpp b/muplug_test/muplug_test.cpp
new file mode 100644
index 0000000..328d0f9
--- /dev/null
+++ b/muplug_test/muplug_test.cpp
@@ -0,0 +1,6 @@
+// muplug_test.cpp : DLL アプリケーション用にエクスポートされる関数を定義します。
+//
+
+#include "stdafx.h"
+
+
diff --git a/muplug_test/muplug_test.sln b/muplug_test/muplug_test.sln
new file mode 100644
index 0000000..39addd5
--- /dev/null
+++ b/muplug_test/muplug_test.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.271
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "muplug_test", "muplug_test.vcxproj", "{356DCF99-2D8A-4047-8BA2-0E3693CA2558}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Debug|x64.ActiveCfg = Debug|x64
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Debug|x64.Build.0 = Debug|x64
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Debug|x86.ActiveCfg = Debug|Win32
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Debug|x86.Build.0 = Debug|Win32
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Release|x64.ActiveCfg = Release|x64
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Release|x64.Build.0 = Release|x64
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Release|x86.ActiveCfg = Release|Win32
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {88821FC9-F18A-49C8-A8D5-656E2358F4FB}
+ EndGlobalSection
+EndGlobal
diff --git a/muplug_test/muplug_test.vcxproj b/muplug_test/muplug_test.vcxproj
new file mode 100644
index 0000000..b654b35
--- /dev/null
+++ b/muplug_test/muplug_test.vcxproj
@@ -0,0 +1,170 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 15.0
+ {356DCF99-2D8A-4047-8BA2-0E3693CA2558}
+ Win32Proj
+ muplugtest
+ 7.0
+
+
+
+ DynamicLibrary
+ true
+ v141
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v141_xp
+ true
+ MultiByte
+
+
+ DynamicLibrary
+ true
+ v141
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v141
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Use
+ Level3
+ Disabled
+ true
+ WIN32;_DEBUG;MUPLUGTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+
+
+
+
+ Use
+ Level3
+ Disabled
+ true
+ _DEBUG;MUPLUGTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+
+
+
+
+ Use
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ WIN32;NDEBUG;MUPLUGTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ MultiThreaded
+
+
+ Windows
+ true
+ true
+ true
+
+
+ copy /Y /V $(TargetPath) ..\\src\\Release
+
+
+
+
+ Use
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ NDEBUG;MUPLUGTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+
+
\ No newline at end of file
diff --git a/muplug_test/muplug_test.vcxproj.filters b/muplug_test/muplug_test.vcxproj.filters
new file mode 100644
index 0000000..2cab2a4
--- /dev/null
+++ b/muplug_test/muplug_test.vcxproj.filters
@@ -0,0 +1,36 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ ヘッダー ファイル
+
+
+ ヘッダー ファイル
+
+
+
+
+ ソース ファイル
+
+
+ ソース ファイル
+
+
+ ソース ファイル
+
+
+
\ No newline at end of file
diff --git a/muplug_test/stdafx.cpp b/muplug_test/stdafx.cpp
new file mode 100644
index 0000000..fd4f341
--- /dev/null
+++ b/muplug_test/stdafx.cpp
@@ -0,0 +1 @@
+#include "stdafx.h"
diff --git a/muplug_test/stdafx.h b/muplug_test/stdafx.h
new file mode 100644
index 0000000..e1cfed9
--- /dev/null
+++ b/muplug_test/stdafx.h
@@ -0,0 +1,24 @@
+// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、
+// または、参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
+// を記述します。
+//
+
+#pragma once
+
+#define MUCOM88WIN
+
+#include
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Windows ヘッダーからほとんど使用されていない部分を除外する
+// Windows ヘッダー ファイル
+#include
+#include
+
+#include "../src/mucom88config.h"
+#include "../src/plugin/mucom88if.h"
+#include "../src/mucomvm.h"
+#include "../src/cmucom.h"
+
+// プログラムに必要な追加ヘッダーをここで参照してください
diff --git a/muplug_test/targetver.h b/muplug_test/targetver.h
new file mode 100644
index 0000000..b99810c
--- /dev/null
+++ b/muplug_test/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// SDKDDKVer.h をインクルードすると、利用できる最も上位の Windows プラットフォームが定義されます。
+
+// 以前の Windows プラットフォーム用にアプリケーションをビルドする場合は、WinSDKVer.h をインクルードし、
+// SDKDDKVer.h をインクルードする前に、サポート対象とするプラットフォームを示すように _WIN32_WINNT マクロを設定します。
+
+#include
diff --git a/package/history.txt b/package/history.txt
index df44172..84197e1 100644
--- a/package/history.txt
+++ b/package/history.txt
@@ -3,6 +3,10 @@ MUCOM88 Windows update history
XV
------------------------------------------------------------------------------
+2019/01/21 ver0.45
+
+ OvOƘAg邽߂̃vOCVXeIɓ
+
2019/01/17 ver0.44
fmgeñXg[ʃXbhň悤ɏC
diff --git a/src/cmucom.cpp b/src/cmucom.cpp
index 125bd53..1ea2eb6 100644
--- a/src/cmucom.cpp
+++ b/src/cmucom.cpp
@@ -136,6 +136,25 @@ void CMucom::Init(void *window, int option, int rate)
vm->SetOption(option);
vm->InitSoundSystem(myrate);
MusicBufferInit();
+ vm->SetMucomInstance(this); // Mucom̃CX^Xʒm(vOCp)
+}
+
+
+int CMucom::AddPlugins(const char *filename, int bootopt)
+{
+ // vOClj
+ // filename = DLLt@C(̂ƂWin̂)
+ // bootopt = NIvV
+ //
+ return vm->AddPlugins(filename, bootopt);
+}
+
+
+void CMucom::NoticePlugins(int cmd, void *p1, void *p2)
+{
+ // vOCʒm
+ //
+ vm->NoticePlugins(cmd,p1,p2);
}
@@ -225,6 +244,8 @@ void CMucom::Reset(int option)
adr = vm->CallAndHaltWithA(0xb00c, i);
vm->SetChDataAddress( i,adr );
}
+
+ NoticePlugins(MUCOM88IF_NOTICE_RESET);
}
void CMucom::SetUUID(char *uuid)
@@ -285,18 +306,27 @@ int CMucom::Play(int num)
}
}
+ // voicet@C[hĂ(FGfBbgp)
+ char voicefile[MUCOM_FILE_MAXSTR];
+ strncpy(voicefile, GetInfoBufferByName("voice"), MUCOM_FILE_MAXSTR);
+ if (voicefile[0]) {
+ LoadFMVoice(voicefile);
+ }
+
vm->SendMem((const unsigned char *)data, 0xc200, datasize);
+ NoticePlugins(MUCOM88IF_NOTICE_PREPLAY);
+
PRINTF("#Play[%d]\r\n", num);
vm->CallAndHalt(0xb000);
//int vec = vm->Peekw(0xf308);
//PRINTF("#INT3 $%x.\r\n", vec);
- vm->StartINT3();
- vm->SetIntCount(0);
+ NoticePlugins(MUCOM88IF_NOTICE_PLAY);
int jcount = hedmusic->jumpcount;
vm->SkipPlay(jcount);
+ vm->StartINT3();
playflag = true;
@@ -379,6 +409,7 @@ int CMucom::Stop(int option)
vm->StopINT3();
vm->CallAndHalt(0xb003);
}
+ NoticePlugins(MUCOM88IF_NOTICE_STOP);
return 0;
}
@@ -441,6 +472,9 @@ int CMucom::LoadMusic(const char * fname, int num)
musbuf[num] = buf;
//if (vm->LoadMem(fname, 0xc200, 0) >= 0) return 0;
+
+ NoticePlugins(MUCOM88IF_NOTICE_LOADMUB);
+
return 0;
}
@@ -803,7 +837,10 @@ int CMucom::Compile(char *text, const char *filename, int option)
}
}
+ NoticePlugins(MUCOM88IF_NOTICE_MMLSEND);
+
basicsize = StoreBasicSource( text, 1, 1 );
+
vm->CallAndHalt(0x9600);
int vec = vm->Peekw(0x0eea8);
PRINTF("#poll a $%x.\r\n", vec);
@@ -880,6 +917,8 @@ int CMucom::Compile(char *text, const char *filename, int option)
if (tcount[maxch-1]==0) pcmflag = 2; // PCM chgĂȂPCMߍ݂̓XLbv
+ NoticePlugins(MUCOM88IF_NOTICE_COMPEND);
+
return SaveMusic(filename,start,length,option| pcmflag);
}
@@ -1197,3 +1236,47 @@ int CMucom::GetChannelData(int ch, PCHDATA *result)
return 0;
}
+/*------------------------------------------------------------*/
+/*
+plugin interface
+*/
+/*------------------------------------------------------------*/
+
+int MUCOM88IF_VM_COMMAND(void *ifptr, int cmd, int prm1, int prm2, void *prm3, void *prm4)
+{
+ // VMpvOCR}h
+ Mucom88Plugin *plg = (Mucom88Plugin *)ifptr;
+ mucomvm *vm = plg->vm; // vmCX^X
+ CMucom *mucom = plg->mucom; // mucomCX^X
+ switch (cmd) {
+ case MUCOM88IF_MUCOMVM_CMD_FMWRITE: // prm1=reg, prm2=data
+ vm->FMRegDataOut( prm1, prm2 );
+ return 0;
+ case MUCOM88IF_MUCOMVM_CMD_FMREAD:
+ break;
+ case MUCOM88IF_MUCOMVM_CMD_GETCHDATA: // prm1=ch, prm3=PCHDATAo͐
+ return mucom->GetChannelData(prm1, (PCHDATA *)prm3);
+ case MUCOM88IF_MUCOMVM_CMD_CHDATA:
+ break;
+ case MUCOM88IF_MUCOMVM_CMD_TAGDATA: // prm3=^O, prm4=o͐(max255chr)
+ {
+ char *result= (char *)prm4;
+ const char *src = (const char *)prm3;
+ const char *p = mucom->GetInfoBufferByName( src );
+ if (p == NULL) return -1;
+ strncpy(result,p,255 );
+ return 0;
+ }
+ }
+ return -1;
+}
+
+
+int MUCOM88IF_EDITOR_COMMAND(void *ifptr, int cmd, int prm1, int prm2, void *prm3, void *prm4)
+{
+ // GfB^pvOCR}h
+ Mucom88Plugin *plg = (Mucom88Plugin *)ifptr;
+ return -1;
+}
+
+
diff --git a/src/cmucom.h b/src/cmucom.h
index 3fc0509..d76afdc 100644
--- a/src/cmucom.h
+++ b/src/cmucom.h
@@ -178,6 +178,8 @@ class CMucom {
~CMucom();
void Init(void *window = NULL, int option = 0, int Rate = 0);
+ int AddPlugins(const char *filename, int bootopt);
+ void NoticePlugins(int cmd, void *p1=NULL, void *p2=NULL);
void Reset(int option=0);
int Play(int num=0);
diff --git a/src/dummy/osdep_dummy.cpp b/src/dummy/osdep_dummy.cpp
index 830e718..9f2921a 100644
--- a/src/dummy/osdep_dummy.cpp
+++ b/src/dummy/osdep_dummy.cpp
@@ -86,12 +86,15 @@ void OsDependentDummy::Delay(int ms) {
}
// プラグイン拡張
-int OsDependentDummy::InitPlugin(Mucom88Plugin *plg, char *filename) {
+int OsDependentDummy::InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt) {
return 0;
}
-int OsDependentDummy::ExecPluginVMCommand( int, int, int, void *, void *) {
+void OsDependentDummy::FreePlugin(Mucom88Plugin *plg) {
+}
+int OsDependentDummy::ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *) {
return 0;
}
-int OsDependentDummy::ExecPluginEditorCommand( int, int, int, void *, void *) {
+int OsDependentDummy::ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *) {
return 0;
-}
\ No newline at end of file
+}
+
diff --git a/src/dummy/osdep_dummy.h b/src/dummy/osdep_dummy.h
index 1eabe28..67e0f35 100644
--- a/src/dummy/osdep_dummy.h
+++ b/src/dummy/osdep_dummy.h
@@ -41,9 +41,10 @@ class OsDependentDummy : public OsDependent {
void Delay(int ms);
// プラグイン拡張
- int InitPlugin(Mucom88Plugin *plg, char *filename);
- int ExecPluginVMCommand( int, int, int, void *, void *);
- int ExecPluginEditorCommand( int, int, int, void *, void *);
+ int InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt);
+ void FreePlugin(Mucom88Plugin *plg);
+ int ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
+ int ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
};
#endif
diff --git a/src/fmgen/file.cpp b/src/fmgen/file.cpp
index c687bf6..6cc465b 100644
--- a/src/fmgen/file.cpp
+++ b/src/fmgen/file.cpp
@@ -36,13 +36,11 @@ FileIO::~FileIO()
bool FileIO::Open(const char* filename, uint flg)
{
Close();
-
strncpy(path, filename, _MAXPATH);
fp = fopen(filename, "rb");
- if (!fp)
- return false;
-
+ if (!fp) return false;
+
SetLogicalOrigin(0);
return true;
@@ -55,13 +53,11 @@ bool FileIO::Open(const char* filename, uint flg)
bool FileIO::CreateNew(const char* filename)
{
Close();
-
strncpy(path, filename, _MAXPATH);
fp = fopen(filename, "wb");
- if (!fp)
- return false;
-
+ if (!fp) return false;
+
SetLogicalOrigin(0);
return !!(flags & open);
@@ -82,12 +78,9 @@ bool FileIO::Reopen(uint flg)
void FileIO::Close()
{
- if (fp)
- fclose(fp);
-
+ if (fp) fclose(fp);
fp = NULL;
-
-}
+ }
// ---------------------------------------------------------------------------
// t@Ck̓ǂݏo
@@ -95,9 +88,8 @@ void FileIO::Close()
int32 FileIO::Read(void* dest, int32 size)
{
- if (!fp)
- return -1;
-
+ if (!fp) return -1;
+
int len = (int)fread(dest, 1, size, fp);
return len;
}
@@ -108,9 +100,8 @@ int32 FileIO::Read(void* dest, int32 size)
int32 FileIO::Write(const void* dest, int32 size)
{
- if (!fp)
- return -1;
-
+ if (!fp) return -1;
+
int len = (int)fwrite(dest, 1, size, fp);
return len;
}
@@ -121,18 +112,17 @@ int32 FileIO::Write(const void* dest, int32 size)
bool FileIO::Seek(int32 pos, SeekMethod method)
{
- if (!fp)
- return -1;
-
+ if (!fp) return false;
+
switch (method)
{
- case begin:
+ case begin:
fseek(fp, pos, SEEK_SET);
break;
case current:
fseek(fp, pos, SEEK_CUR);
break;
- case end:
+ case end:
fseek(fp, pos, SEEK_END);
break;
default:
@@ -148,9 +138,8 @@ bool FileIO::Seek(int32 pos, SeekMethod method)
int32 FileIO::Tellp()
{
- if (!fp)
- return -1;
-
+ if (!fp) return -1;
+
return (int)ftell(fp);
}
diff --git a/src/main.cpp b/src/main.cpp
index 774dea3..281e358 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,6 +38,9 @@ static const char *p[] = {
" -w [filename] set output WAV file name",
" -c [filename] compile mucom88 MML file name",
" -i [filename] info print mucom88 MML file name",
+#ifdef MUCOM88WIN
+ " -a [filename] add external plugin",
+#endif
" -e Use external ROM files",
" -s Use SCCI device",
" -k Skip PCM load",
@@ -63,6 +66,7 @@ int main( int argc, char *argv[] )
const char *outfile;
const char *wavfile;
const char *voicefile;
+ const char *pluginfile;
#if defined(USE_SDL) && defined(_WIN32)
freopen( "CON", "w", stdout );
@@ -108,6 +112,7 @@ int main( int argc, char *argv[] )
outfile = DEFAULT_OUTFILE;
wavfile = DEFAULT_OUTWAVE;
voicefile = NULL;
+ pluginfile = NULL;
fname[0] = 0;
int song_length = RENDER_SECONDS;
@@ -131,6 +136,9 @@ int main( int argc, char *argv[] )
case 'w':
wavfile = argv[b + 1]; b++;
break;
+ case 'a':
+ pluginfile = argv[b + 1]; b++;
+ break;
case 'l':
song_length = atoi(argv[b + 1]); b++;
break;
@@ -176,6 +184,14 @@ int main( int argc, char *argv[] )
mucom.SetVMOption(MUCOM_OPTION_SCCI | MUCOM_OPTION_FMMUTE, 1);
}
+ if (pluginfile) {
+ printf("#Adding plugin %s.\n", pluginfile);
+ int plgres = mucom.AddPlugins(pluginfile,0);
+ if (plgres) {
+ printf( "#Error adding plugin.(%d)\n", plgres );
+ }
+ }
+
mucom.Reset(cmpopt);
st = 0;
diff --git a/src/mucomvm.cpp b/src/mucomvm.cpp
index 59c5ec4..7c5b1bf 100644
--- a/src/mucomvm.cpp
+++ b/src/mucomvm.cpp
@@ -19,6 +19,8 @@
#include "mucomvm_os.h"
+static OsDependent *master_osd = NULL;
+
/*------------------------------------------------------------*/
/*
interface
@@ -47,6 +49,8 @@ mucomvm::mucomvm(void)
mucomvm::~mucomvm(void)
{
+ FreePlugins();
+
if (osd) {
osd->FreeTimer();
osd->FreeAudio();
@@ -67,6 +71,12 @@ mucomvm::~mucomvm(void)
}
+void mucomvm::SetMucomInstance(CMucom *mucom)
+{
+ p_cmucom = mucom;
+}
+
+
void mucomvm::SetOption(int option)
{
m_flag = 0;
@@ -149,11 +159,9 @@ void mucomvm::InitSoundSystem(int rate)
predelay = 0;
// OSˑ
- {
- osd = new OSDEP_CLASS();
- }
-
+ osd = new OSDEP_CLASS();
if (osd == NULL) return;
+ master_osd = osd; // vOCp
// COM
//
@@ -728,6 +736,7 @@ void mucomvm::SkipPlay(int count)
int vec = Peekw(0xf308); // INT3 vector擾
SetChMuteAll(true);
+ busyflag = true; // Z80VM2dNh~
while (1) {
if (jcount <= 0) break;
CallAndHalt(vec);
@@ -737,6 +746,7 @@ void mucomvm::SkipPlay(int count)
if ((jcount & 3) == 0) osd->Delay(1); // Ƒ҂܂
}
}
+ busyflag = false;
SetChMuteAll(false);
}
@@ -795,6 +805,7 @@ void mucomvm::UpdateTime(int base)
}
busyflag = false;
ProcessChData();
+ NoticePlugins(MUCOM88IF_NOTICE_INTDONE, NULL, NULL); // vOCɒʒm
}
else {
predelay--;
@@ -883,10 +894,22 @@ FM synth
*/
/*------------------------------------------------------------*/
+void mucomvm::FMRegDataOut(int reg, int data)
+{
+ regmap[reg] = (uint8_t)data; // WX^ێp
+ opn->SetReg(reg, data);
+
+ if (m_option & VM_OPTION_SCCI) {
+ // A`bvo
+ osd->OutputRealChip(reg, data);
+ }
+}
+
// f[^o
void mucomvm::FMOutData(int data)
{
//printf("FMReg: %04x = %02x\n", sound_reg_select, data);
+
switch (sound_reg_select) {
case 0x28:
{
@@ -907,12 +930,8 @@ void mucomvm::FMOutData(int data)
default:
break;
}
- opn->SetReg(sound_reg_select, data);
- if (m_option & VM_OPTION_SCCI) {
- // A`bvo
- osd->OutputRealChip(sound_reg_select, data);
- }
+ FMRegDataOut(sound_reg_select, data);
}
// f[^o(OPNA)
@@ -925,12 +944,7 @@ void mucomvm::FMOutData2(int data)
if (data & 0x80) chstat[OPNACH_ADPCM] = 1; else chstat[OPNACH_ADPCM] = 0;
}
- opn->SetReg(sound_reg_select2 | 0x100, data);
-
- if (m_option & VM_OPTION_SCCI) {
- // A`bvo
- osd->OutputRealChip(sound_reg_select2 | 0x100, data);
- }
+ FMRegDataOut(sound_reg_select2 | 0x100, data);
}
// f[^
@@ -1095,3 +1109,59 @@ void mucomvm::ProcessChData(void)
}
+/*------------------------------------------------------------*/
+/*
+plugin interface
+*/
+/*------------------------------------------------------------*/
+
+int MUCOM88IF_VM_COMMAND(void *ifptr, int cmd, int prm1, int prm2, void *prm3, void *prm4);
+int MUCOM88IF_EDITOR_COMMAND(void *ifptr, int cmd, int prm1, int prm2, void *prm3, void *prm4);
+
+int mucomvm::AddPlugins(const char *filename, int bootopt)
+{
+ // vOClj
+ // filename = vOCDLL
+ // bootopt = NIvV(gp)
+ // IR[h : 0=OK
+ //
+ int res;
+ Mucom88Plugin *plg = new Mucom88Plugin;
+ plg->if_mucomvm = (MUCOM88IF_COMMAND)MUCOM88IF_VM_COMMAND;
+ plg->if_editor = (MUCOM88IF_COMMAND)MUCOM88IF_EDITOR_COMMAND;
+ plg->mucom = p_cmucom;
+ plg->vm = this;
+ plg->hwnd = master_window;
+ strncpy( plg->filename, filename, MUCOM88IF_FILENAME_MAX-1 );
+ plugins.push_back(plg);
+ res = osd->InitPlugin(plg, filename, bootopt);
+ if (res) return res;
+ plg->if_notice(plg, MUCOM88IF_NOTICE_BOOT,NULL,NULL); // ʒm
+ return 0;
+}
+
+
+void mucomvm::FreePlugins(void)
+{
+ // vOCׂĔj
+ //
+ Mucom88Plugin *plg;
+ for (auto it = begin(plugins); it != end(plugins); ++it) {
+ plg = *it;
+ plg->if_notice(plg, MUCOM88IF_NOTICE_TERMINATE, NULL, NULL); // jOɒʒm
+ osd->FreePlugin(plg);
+ }
+ plugins.clear(); // ׂč폜
+}
+
+
+void mucomvm::NoticePlugins(int cmd, void *p1, void *p2)
+{
+ Mucom88Plugin *plg;
+ for (auto it = begin(plugins); it != end(plugins); ++it) {
+ plg = *it;
+ plg->if_notice(plg, cmd, p1, p2);
+ }
+}
+
+
diff --git a/src/mucomvm.h b/src/mucomvm.h
index fc32bc4..32c3960 100644
--- a/src/mucomvm.h
+++ b/src/mucomvm.h
@@ -65,6 +65,7 @@ class mucomvm : public Z80 {
void PlayLoop(void);
// z}VXe[^X
+ uint8_t *GetMemoryMap(void) { return mem; }
int GetFlag(void) { return m_flag; }
int Peek(uint16_t adr);
int Peekw(uint16_t adr);
@@ -84,10 +85,12 @@ class mucomvm : public Z80 {
int GetPassTick(void) { return pass_tick; }
// YM2608Xe[^X
+ void FMRegDataOut(int reg, int data);
void SetChMuteAll(bool sw);
void SetChMute(int ch, bool sw);
bool GetChMute(int ch);
int GetChStatus(int ch);
+ uint8_t *GetRegisterMap(void) { return regmap; }
// fobOp
void Msgf(const char *format, ...);
@@ -116,6 +119,12 @@ class mucomvm : public Z80 {
void UpdateTime(int tick);
void UpdateCallback(int tick);
+ // vOCRg[
+ void SetMucomInstance(CMucom *mucom);
+ int AddPlugins(const char *filename, int bootopt);
+ void FreePlugins(void);
+ void NoticePlugins(int cmd, void *p1 = NULL, void *p2=NULL);
+
private:
// Z80
int32_t load(uint16_t adr);
@@ -178,6 +187,12 @@ class mucomvm : public Z80 {
OsDependent *osd;
void *master_window;
+ // vOCg(p)
+ std::vector plugins;
+
+ // ẽCX^X(Q)
+ CMucom *p_cmucom;
+
};
diff --git a/src/mucomvm_os.h b/src/mucomvm_os.h
index 59ba7e8..42f9378 100644
--- a/src/mucomvm_os.h
+++ b/src/mucomvm_os.h
@@ -1,6 +1,6 @@
#ifdef MUCOM88WIN
-#include "win32/osdep_win.h" // とりあえず仮作成中
+#include "win32/osdep_win.h"
#define OSDEP_CLASS OsDependentWin32
#elif defined USE_SDL
#include "sdl/osdep_sdl.h"
diff --git a/src/osdep.cpp b/src/osdep.cpp
index 58ac07b..c2b6b07 100644
--- a/src/osdep.cpp
+++ b/src/osdep.cpp
@@ -9,18 +9,6 @@
#include
#include "osdep.h"
-static int MUCOM88IF_VM_COMMAND(int cmd, int prm1, int prm2, void *prm3, void *prm4)
-{
- return 0;
-}
-
-
-static int MUCOM88IF_EDITOR_COMMAND(int cmd, int prm1, int prm2, void *prm3, void *prm4)
-{
- return 0;
-}
-
-
OsDependent::OsDependent(void)
{
}
@@ -29,28 +17,3 @@ OsDependent::~OsDependent(void)
{
}
-int OsDependent::AddPlugins(char *filename)
-{
- // vOClj
- // filename = vOCDLL
- //
- Mucom88Plugin *plg = new Mucom88Plugin;
- plg->if_mucomvm = (MUCOM88IF_COMMAND)MUCOM88IF_VM_COMMAND;
- plg->if_editor = (MUCOM88IF_COMMAND)MUCOM88IF_EDITOR_COMMAND;
- plugins.push_back(plg);
- return InitPlugin(plg, filename);
-}
-
-
-void OsDependent::FreePlugins(void)
-{
-
-}
-
-
-void OsDependent::NoticePlugins(int cmd)
-{
-
-}
-
-
diff --git a/src/osdep.h b/src/osdep.h
index c158f58..dc5ecc6 100644
--- a/src/osdep.h
+++ b/src/osdep.h
@@ -52,17 +52,12 @@ class OsDependent {
virtual void Delay(int ms)=0;
// vOCg
- virtual int InitPlugin(Mucom88Plugin *plg, char *filename) = 0;
- virtual int ExecPluginVMCommand(int, int, int, void *, void *) = 0;
- virtual int ExecPluginEditorCommand(int, int, int, void *, void *) = 0;
+ virtual int InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt) = 0;
+ virtual void FreePlugin(Mucom88Plugin *plg) = 0;
+ virtual int ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *) = 0;
+ virtual int ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *) = 0;
protected:
- // vOCg(p)
- std::vector plugins;
-
- int AddPlugins(char *filename);
- void FreePlugins(void);
- void NoticePlugins(int cmd);
};
diff --git a/src/plugin/mucom88if.h b/src/plugin/mucom88if.h
index cf727a8..565a5d3 100644
--- a/src/plugin/mucom88if.h
+++ b/src/plugin/mucom88if.h
@@ -12,8 +12,10 @@
// t@NV^
//
typedef int (*MUCOM88IF_COMMAND) (void *,int,int,int,void *,void *);
-typedef int(*MUCOM88IF_CALLBACK)(void *, int);
-typedef int(*MUCOM88IF_STARTUP)(void *);
+typedef int(*MUCOM88IF_CALLBACK)(void *, int, void *, void *);
+
+typedef int(*MUCOM88IF_STARTUP)(void *, int);
+
#define MUCOM88IF_VERSION 0x100 // 1.0
@@ -23,15 +25,18 @@ typedef int(*MUCOM88IF_STARTUP)(void *);
// if_noticeŒʒmR[h
#define MUCOM88IF_NOTICE_NONE 0
-#define MUCOM88IF_NOTICE_RESET 1 // VMZbg(RpCAtJn)
-#define MUCOM88IF_NOTICE_DRVINT 2 // VMhCos(荞݃^C~O)
-#define MUCOM88IF_NOTICE_TOOLSTART 3 // vOCc[NNGXg
-#define MUCOM88IF_NOTICE_PREPLAY 4 // tJnO(MUBǂݍݒ)
-#define MUCOM88IF_NOTICE_PLAY 5 // tJn
-#define MUCOM88IF_NOTICE_STOP 6 // t~
-#define MUCOM88IF_NOTICE_MMLSEND 7 // RpCMMLm莞
-#define MUCOM88IF_NOTICE_COMPEND 8 // RpCI
-#define MUCOM88IF_NOTICE_LOADMUB 9 // MUBǂݍ
+#define MUCOM88IF_NOTICE_BOOT 0x1000 // ŏ̏(N̂)
+#define MUCOM88IF_NOTICE_TERMINATE 0x1001 // I()
+#define MUCOM88IF_NOTICE_INTDONE 0x1002 // t荞(t[`s)
+#define MUCOM88IF_NOTICE_RESET 1 // VMZbg(RpCAtJn)
+#define MUCOM88IF_NOTICE_DRVINT 2 // VMhCos(荞݃^C~O)
+#define MUCOM88IF_NOTICE_TOOLSTART 3 // vOCc[NNGXg
+#define MUCOM88IF_NOTICE_PREPLAY 4 // tJnO(MUBǂݍݒ)
+#define MUCOM88IF_NOTICE_PLAY 5 // tJn
+#define MUCOM88IF_NOTICE_STOP 6 // t~
+#define MUCOM88IF_NOTICE_MMLSEND 7 // RpCMMLm莞
+#define MUCOM88IF_NOTICE_COMPEND 8 // RpCI
+#define MUCOM88IF_NOTICE_LOADMUB 9 // MUBǂݍ
// if_editorŎgpR}h
#define MUCOM88IF_EDITOR_CMD_NONE 0
@@ -45,9 +50,9 @@ typedef int(*MUCOM88IF_STARTUP)(void *);
#define MUCOM88IF_MUCOMVM_CMD_NONE 0
#define MUCOM88IF_MUCOMVM_CMD_FMWRITE 1 // FMWX^ɏ
#define MUCOM88IF_MUCOMVM_CMD_FMREAD 2 // FMWX^̃e[u擾
-#define MUCOM88IF_MUCOMVM_CMD_GETCHDATA 2 // ch̉tf[^擾
-#define MUCOM88IF_MUCOMVM_CMD_CHDATA 3 // ch̉tf[^擾
-#define MUCOM88IF_MUCOMVM_CMD_TAGDATA 4 // TAGf[^擾
+#define MUCOM88IF_MUCOMVM_CMD_GETCHDATA 3 // ch̉tf[^擾
+#define MUCOM88IF_MUCOMVM_CMD_CHDATA 4 // ch̉tf[^擾
+#define MUCOM88IF_MUCOMVM_CMD_TAGDATA 5 // TAGf[^擾
class mucomvm;
@@ -73,12 +78,10 @@ class Mucom88Plugin {
int type; // vOC^Cv(*)
const char *info; // vOCeLXg̃|C^(*)
- // R[obNt@NV
- MUCOM88IF_CALLBACK if_init; // (ŏ1̂)
- MUCOM88IF_CALLBACK if_term; //
- MUCOM88IF_CALLBACK if_notice; // R}hʒm
+ // R[obNt@NV(vOCݒ肵܂)
+ MUCOM88IF_CALLBACK if_notice; // R}hʒm(*)
- // ėpt@NV
+ // ėpt@NV(ݒ肳܂)
//
MUCOM88IF_COMMAND if_mucomvm; // MUCOM88 VM̃ANZX
MUCOM88IF_COMMAND if_editor; // GfB^ñT[rX
diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp
index cb1704a..d2a7d36 100644
--- a/src/plugin/plugin.cpp
+++ b/src/plugin/plugin.cpp
@@ -11,13 +11,9 @@
#include "plugin.h"
-int dummyCommand(void *instance, int cmd, int prm1, int prm2, void *prm3, void *prm4)
-{
- return 0;
-}
-
-int dummyCallback(void *instance, int cmd)
+int dummyCallback(void *instance, int cmd, void *p1, void *p2)
{
+ Mucom88Plugin *plg = (Mucom88Plugin *)instance;
return 0;
}
@@ -32,14 +28,12 @@ Mucom88Plugin::Mucom88Plugin()
info = ""; // vOCeLXg̃|C^(*)
// R[obNt@NV
- if_init = dummyCallback;
- if_term = dummyCallback;
if_notice = dummyCallback;
// ėpt@NV
//
- if_mucomvm = dummyCommand;
- if_editor = dummyCommand;
+ if_mucomvm = NULL;
+ if_editor = NULL;
// NX (o[WœeύX̉\܂)
vm = NULL;
diff --git a/src/sdl/osdep_sdl.cpp b/src/sdl/osdep_sdl.cpp
index bbf7e21..23cca89 100644
--- a/src/sdl/osdep_sdl.cpp
+++ b/src/sdl/osdep_sdl.cpp
@@ -214,13 +214,15 @@ void OsDependentSdl::Delay(int ms) {
}
// プラグイン拡張
-int OsDependentSdl::InitPlugin(Mucom88Plugin *plg, char *filename) {
+int OsDependentDummy::InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt) {
return 0;
}
-int OsDependentSdl::ExecPluginVMCommand( int, int, int, void *, void *) {
+void OsDependentDummy::FreePlugin(Mucom88Plugin *plg) {
+}
+int OsDependentDummy::ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *) {
return 0;
}
-int OsDependentSdl::ExecPluginEditorCommand( int, int, int, void *, void *) {
+int OsDependentDummy::ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *) {
return 0;
}
diff --git a/src/sdl/osdep_sdl.h b/src/sdl/osdep_sdl.h
index 68eddf8..358d54d 100644
--- a/src/sdl/osdep_sdl.h
+++ b/src/sdl/osdep_sdl.h
@@ -46,9 +46,10 @@ class OsDependentSdl : public OsDependent {
void Delay(int ms);
// プラグイン拡張
- int InitPlugin(Mucom88Plugin *plg, char *filename);
- int ExecPluginVMCommand( int, int, int, void *, void *);
- int ExecPluginEditorCommand( int, int, int, void *, void *);
+ int InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt);
+ void FreePlugin(Mucom88Plugin *plg);
+ int ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
+ int ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
AudioBuffer *Buffer;
AudioTimeInfo *Time;
diff --git a/src/win32/osdep_win.cpp b/src/win32/osdep_win.cpp
index ab4098c..26a3342 100644
--- a/src/win32/osdep_win.cpp
+++ b/src/win32/osdep_win.cpp
@@ -303,7 +303,9 @@ bool OsDependentWin32::InitAudio(void *hwnd, int Rate, int BufferSize) {
// ^C}[
//
// Xg[pXbh
- StartThread();
+ if (RealChipInstance == NULL) {
+ StartThread();
+ }
return true;
}
@@ -368,23 +370,57 @@ void OsDependentWin32::StreamSend(int ms)
-// MUCOMvOCp
+// MUCOM88WinvOCp
//
+int OsDependentWin32::InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt)
+{
+ // DLLNď
+ //
+ HMODULE hInst = NULL;
+ plg->instance = NULL;
+
+ // DLLǂݍ
+ hInst = ::LoadLibrary(filename);
+ if (hInst == NULL) {
+ return GetLastError();
+ }
+ // AhX擾
+ MUCOM88IF_STARTUP initalize = (MUCOM88IF_STARTUP)(::GetProcAddress(hInst, "InitalizePlugin"));
+
+ if (initalize == NULL) {
+ ::FreeLibrary(hInst);
+ return GetLastError();
+ }
-int OsDependentWin32::InitPlugin(Mucom88Plugin *plg, char *filename)
+ //
+ return initalize(plg,bootopt);
+}
+
+
+void OsDependentWin32::FreePlugin(Mucom88Plugin *plg)
{
- return 0;
+ // DLL
+ //
+ HMODULE hInst = (HMODULE)plg->instance;
+ if (hInst == NULL) return;
+
+ ::FreeLibrary(hInst);
+ plg->instance = NULL;
}
-int OsDependentWin32::ExecPluginVMCommand(int, int, int, void *, void *)
+int OsDependentWin32::ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *)
{
+ // OSˑ̃vOCVMR}h
+ //
return 0;
}
-int OsDependentWin32::ExecPluginEditorCommand(int, int, int, void *, void *)
+int OsDependentWin32::ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *)
{
+ // OSˑ̃vOCGfB^R}h
+ //
return 0;
}
diff --git a/src/win32/osdep_win.h b/src/win32/osdep_win.h
index 4114ba2..6a60b77 100644
--- a/src/win32/osdep_win.h
+++ b/src/win32/osdep_win.h
@@ -45,14 +45,12 @@ class OsDependentWin32 : public OsDependent {
void Delay(int ms);
// vOCg
- int InitPlugin(Mucom88Plugin *plg, char *filename);
- int ExecPluginVMCommand( int, int, int, void *, void *);
- int ExecPluginEditorCommand( int, int, int, void *, void *);
+ int InitPlugin(Mucom88Plugin *plg, const char *filename, int bootopt);
+ void FreePlugin(Mucom88Plugin *plg);
+ int ExecPluginVMCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
+ int ExecPluginEditorCommand(Mucom88Plugin *plg, int, int, int, void *, void *);
private:
- // eVMCX^X
- mucomvm *vm;
-
// TEhĐ
WinSoundDriver::DriverDS *snddrv;
HWND master_window;