From ab379f2bb081f3fe2ea77ed163f755f59a49e6cf Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Wed, 12 Apr 2017 01:04:15 +0900 Subject: added wave output --- common/fmplayer_drumrom_win.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 common/fmplayer_drumrom_win.c (limited to 'common/fmplayer_drumrom_win.c') diff --git a/common/fmplayer_drumrom_win.c b/common/fmplayer_drumrom_win.c new file mode 100644 index 0000000..aab4546 --- /dev/null +++ b/common/fmplayer_drumrom_win.c @@ -0,0 +1,49 @@ +#include "fmplayer_common.h" +#include "libopna/opnadrum.h" +#define WIN32_LEAN_AND_MEAN +#include +#include +static struct { + char drum_rom[OPNA_ROM_SIZE]; + bool loaded; +} g; + +static void loadrom(void) { + const wchar_t *path = L"ym2608_adpcm_rom.bin"; + wchar_t exepath[MAX_PATH]; + if (GetModuleFileName(0, exepath, MAX_PATH)) { + PathRemoveFileSpec(exepath); + if ((lstrlen(exepath) + lstrlen(path) + 1) < MAX_PATH) { + lstrcat(exepath, L"\\"); + lstrcat(exepath, path); + path = exepath; + } + } + HANDLE file = CreateFile(path, GENERIC_READ, + 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (file == INVALID_HANDLE_VALUE) goto err; + DWORD filesize = GetFileSize(file, 0); + if (filesize != OPNA_ROM_SIZE) goto err; + DWORD readbytes; + if (!ReadFile(file, g.drum_rom, OPNA_ROM_SIZE, &readbytes, 0) + || readbytes != OPNA_ROM_SIZE) goto err; + CloseHandle(file); + g.loaded = true; + return; +err: + if (file != INVALID_HANDLE_VALUE) CloseHandle(file); + return; +} + + +bool fmplayer_drum_rom_load(struct opna_drum *drum) { + if (!g.loaded) loadrom(); + if (g.loaded) { + opna_drum_set_rom(drum, g.drum_rom); + } + return g.loaded; +} + +bool fmplayer_drum_loaded(void) { + return g.loaded; +} -- cgit v1.2.3