-
o
-
-
C`bg
-
ANZX
第1弾 ---- 偽物のMSXGr.dllを用意して MSXPLAYer for MSX Game Reader で使ってみる
Fedoraでの画面(Linuxなので、Wineを利用して普通のWindows用アプリを動かすことはできるかもしれないけどゲームリーダー付属のデバイスドライバは使えないはず)
いきなり趣旨と反するようにも思えますが、まずは本物のMSXゲームリーダーを使わずに偽物のMSXGr.dllを用意して、ゲームリーダー用のMSXPLAYerを動かす実験です。
本物のROMカートリッジではなく"C:\MSX\romimage.rom"に置いたROMイメージファイルを使います。面倒なのでパスもファイル名も固定です。
32KバイトのROMとコナミのSCC内蔵メガROMに対応しているつもりです。不具合があるかもしれませんが、それなりに動作します。
ROMイメージファイルを使うんだったらMSXPLAYerじゃなくて他のエミュレータを使えば良いだろうと思われそうですが、これは実験です。
本物のMSXGr.dllがあれば一旦リネームするなどしておいてから、このMSXGr.dllをパスの通った場所に置いて下さい。
DLLファイルは配布しません。C言語のソースだけ置いておきます。
DLLファイルの作り方は、C言語のソースの中にコメントで書いています。
C言語 MSXGr.c
/* ----------------------------------------------------------------------- file: MSXGr.c version: 0.0.0.1 (2020/01/31) description: This is a source file of fake "MSXGr.dll". "MSXPLAYer for MSX Game Reader" will work without real GameReader. "C:\MSX\romimage.rom" should be "Normal 32K ROM" or "Konami MegaROM with SCC". I learned from "grdump-0.5d.zip". This is an experimental program. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. See https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt for more details. Copyright 2020 umaiboux ----------------------------------------------------------------------- */ /* (How to build DLL) If you can use Microsoft Visual C++ Command Prompt for Win32, try this: cl /LD MSXGr.c If you can use MSYS2, try this: gcc -shared -mwindows -o MSXGr.dll MSXGr.c If you can use Borland C++ 5.5.1 for Win32, try this: bcc32 -tWD -tWM -vu MSXGr.c If you can use Embarcadero C++ 7.40 for Win32 (C++Builder 10.3 Community Edition) Command Prompt, try this: bcc32 -tD -tM -vu MSXGr.c Or bcc32 users may use "MSXGr.def" file instead of "-vu" option. ; MSXGr.def ; for BCC32.exe EXPORTS MSXGR_Init = _MSXGR_Init MSXGR_Uninit = _MSXGR_Uninit MSXGR_Err2Str = _MSXGR_Err2Str MSXGR_GetVersion = _MSXGR_GetVersion MSXGR_SetDebugMode = _MSXGR_SetDebugMode MSXGR_IsSlotEnable = _MSXGR_IsSlotEnable MSXGR_GetSlotStatus = _MSXGR_GetSlotStatus MSXGR_ReadMemory = _MSXGR_ReadMemory MSXGR_WriteMemory = _MSXGR_WriteMemory MSXGR_ReadIO = _MSXGR_ReadIO MSXGR_WriteIO = _MSXGR_WriteIO MSXGR_SetEventNotification = _MSXGR_SetEventNotification */ #define WIN32_LEAN_AND_MEAN #include
#define DEF_false 0 #define DEF_true 1 #define DEF_bool char #define DEF_ERR1 1 #if defined(__cplusplus) #define DEF_ENTRY extern "C" #else #define DEF_ENTRY #endif char g_rompath[MAX_PATH * 2] = "C:\\MSX\\romimage.rom"; char g_romimg[0x2000 * 0x40]; DWORD g_romsize; DEF_bool g_inserted; int g_rombank[4]; DEF_bool g_sccbank; char g_sccwave[0x80]; int g_bankmask; /* char g_exepath[MAX_PATH * 2]; char g_dllpath[MAX_PATH * 2]; */ #if !defined(_WIN32) || defined(_WIN64) #error "not 32bit" #endif #if defined(__BORLANDC__) BOOL APIENTRY DllEntryPoint( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) #else BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) #endif { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: /* GetModuleFileNameA(NULL, g_exepath, sizeof(g_exepath)); GetModuleFileNameA(hModule, g_dllpath, sizeof(g_dllpath)); */ break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: /* MessageBoxA(NULL, g_exepath, "exepath", MB_ICONINFORMATION); MessageBoxA(NULL, g_dllpath, "dllpath", MB_ICONINFORMATION); */ break; } return TRUE; } /* __declspec(dllexport) typedef int (__cdecl *_MSXGR_Init)(); typedef void (__cdecl *_MSXGR_Uninit)(); typedef char* (__cdecl *_MSXGR_Err2Str)(int); typedef int (__cdecl *_MSXGR_GetVersion)(); typedef void (__cdecl *_MSXGR_SetDebugMode)(int); typedef bool (__cdecl *_MSXGR_IsSlotEnable)(int); typedef int (__cdecl *_MSXGR_GetSlotStatus)(int,int*); typedef int (__cdecl *_MSXGR_ReadMemory)(int,char*,int,int); typedef int (__cdecl *_MSXGR_WriteMemory)(int,char*,int,int); typedef int (__cdecl *_MSXGR_ReadIO)(int,char*,int,int); typedef int (__cdecl *_MSXGR_WriteIO)(int,char*,int,int); typedef int (__cdecl *_MSXGR_SetEventNotification)(int); */ DEF_ENTRY __declspec(dllexport) int MSXGR_Init(void); DEF_ENTRY __declspec(dllexport) void MSXGR_Uninit(void); DEF_ENTRY __declspec(dllexport) char* MSXGR_Err2Str(int); DEF_ENTRY __declspec(dllexport) int MSXGR_GetVersion(void); DEF_ENTRY __declspec(dllexport) void MSXGR_SetDebugMode(int); DEF_ENTRY __declspec(dllexport) DEF_bool MSXGR_IsSlotEnable(int); DEF_ENTRY __declspec(dllexport) int MSXGR_GetSlotStatus(int,int*); DEF_ENTRY __declspec(dllexport) int MSXGR_ReadMemory(int,char*,int,int); DEF_ENTRY __declspec(dllexport) int MSXGR_WriteMemory(int,char*,int,int); DEF_ENTRY __declspec(dllexport) int MSXGR_ReadIO(int,char*,int,int); DEF_ENTRY __declspec(dllexport) int MSXGR_WriteIO(int,char*,int,int); DEF_ENTRY __declspec(dllexport) int MSXGR_SetEventNotification(int); int MSXGR_Init(void) { HANDLE hFile; g_romimg[0] = g_romimg[0x4000] = 0; g_inserted = DEF_false; g_romsize = 0; g_rombank[0] = 0; g_rombank[1] = 1; g_rombank[2] = 2; g_rombank[3] = 3; g_sccbank = DEF_false; hFile = CreateFile(g_rompath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return 0; } if (ReadFile( hFile, g_romimg, sizeof(g_romimg), &g_romsize, NULL)) { g_inserted = DEF_true; if (g_romsize <= 0x2000 * 0x10) g_bankmask = 0x0F; else if (g_romsize <= 0x2000 * 0x20) g_bankmask = 0x1F; else g_bankmask = 0x3F; } CloseHandle(hFile); return 0; } void MSXGR_Uninit(void) { } char* MSXGR_Err2Str(int nError) { return "MSXGR_Err2Str is not implemented."; } int MSXGR_GetVersion(void) { /* return 0x01234567; */ return 0x00000001; } void MSXGR_SetDebugMode(int nLevel) { } DEF_bool MSXGR_IsSlotEnable(int nSlot) { if (nSlot != 0) { return DEF_false; } return DEF_true; } int MSXGR_GetSlotStatus(int nSlot,int *pBuffer) { if (nSlot != 0) { return DEF_ERR1; } pBuffer[0] = 01; /* slot enable */ pBuffer[1] = g_inserted ? 0xff : 0; /* cartridge inserted */ pBuffer[2] = 0; /* ? */ return 0; } int MSXGR_ReadMemory(int nSlot,char* pBuffer,int nAddress,int nLength) { int bank; int i; if (nSlot != 0) { return DEF_ERR1; } if (g_romsize <= 0x8000) { nAddress -= 0x4000; for(i=0; i
0xBFFF)) { pBuffer[i] = 0xFF; continue; } bank = (nAddress - 0x4000) >> 13; if (!g_sccbank || bank != 2) { pBuffer[i] = g_romimg[g_rombank[bank]*0x2000 + (nAddress & 0x1FFF)]; } else { int offset = nAddress & 0xFF; pBuffer[i] = offset < 0x80 ? g_sccwave[offset] : 0xFF; } } return 0; } int MSXGR_WriteMemory(int nSlot,char* pBuffer,int nAddress,int nLength) { int bank; int offset; int i; if (nSlot != 0) { return DEF_ERR1; } if (g_romsize <= 0x8000) { return 0; } for(i=0; i
0xBFFF)) continue; bank = (nAddress - 0x4000) >> 13; offset = nAddress & 0x1FFF; if (g_sccbank && (nAddress >= 0x9800) && (nAddress <= 0x9FFF)) { offset = nAddress & 0xFF; if (offset < 0x80) { g_sccwave[offset] = pBuffer[i]; } continue; } if ((offset < 0x1000) || (offset > 0x17FF)){ continue; } if (bank == 2) { g_sccbank = ((pBuffer[i] & 0x3F) == 0x3F); } g_rombank[bank] = pBuffer[i] & g_bankmask; } return 0; } int MSXGR_ReadIO(int nSlot,char* pBuffer,int nAddress,int nLength) { int i; if (nSlot != 0) { return DEF_ERR1; } for(i=0; i
戻る
ANZX
SEO
/
SEO
FC2
:
Text
AD
:
JEFFC2
z[y[W
T[rXLO
VbsOJ[g
BBS
Cu`bg
JE^[
[
hCo^798~`
^T[o[
AvP[VJ
Io