From a7f3e786ede2fd40fbc86035f6600a2b3b415dfd Mon Sep 17 00:00:00 2001 From: ayuanx Date: Thu, 24 Oct 2024 22:05:08 +1100 Subject: [PATCH] Add an option to customize the music folder name. --- README.md | 3 +++ ogg-winmm.c | 25 ++++++++++++++----------- resource/winmm.ini | 10 +++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e14dc1d..c191ce4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ NOTE: It actually can also work on Win95/98 if you follow the extra procedure be # Revisions: +v.2024.10.24 +- Add an option to customize the music folder name. + v.2024.08.08 - Small compiler optimizations. diff --git a/ogg-winmm.c b/ogg-winmm.c index f9dcc04..983e2e6 100644 --- a/ogg-winmm.c +++ b/ogg-winmm.c @@ -57,7 +57,8 @@ HANDLE event = NULL; HWND window = NULL; const char alias_def[] = "cdaudio"; char alias_s[100] = "cdaudio"; -char music_path[MAX_PATH]; +char path[MAX_PATH]; +char cddaPath[MAX_PATH]; int mode = MCI_MODE_STOP; int command = 0; @@ -125,15 +126,16 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) #ifdef _DEBUG fh = fopen("winmm.log", "w"); #endif - GetModuleFileName(hinstDLL, music_path, sizeof(music_path)); + GetModuleFileName(hinstDLL, path, sizeof(path)); - char *last = strrchr(music_path, '.'); + char *last = strrchr(path, '.'); if (last) { strcpy(last, ".ini"); - cddaVol = GetPrivateProfileInt("OGG-WinMM", "CDDAVolume", 100, music_path); - midiVol = GetPrivateProfileInt("OGG-WinMM", "MIDIVolume", 100, music_path); - waveVol = GetPrivateProfileInt("OGG-WinMM", "WAVEVolume", 100, music_path); + GetPrivateProfileString("OGG-WinMM", "CDDAPath", "Music", cddaPath, MAX_PATH, path); + cddaVol = GetPrivateProfileInt("OGG-WinMM", "CDDAVolume", 100, path); + midiVol = GetPrivateProfileInt("OGG-WinMM", "MIDIVolume", 100, path); + waveVol = GetPrivateProfileInt("OGG-WinMM", "WAVEVolume", 100, path); if (cddaVol < 0 || cddaVol > 100 ) cddaVol = 100; if (midiVol < 0 || midiVol > 100 ) midiVol = 100; @@ -144,19 +146,20 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) stub_wavevol(waveVol); } - last = strrchr(music_path, '\\'); + last = strrchr(path, '\\'); if (last) *last = '\0'; - strcat(music_path, "\\MUSIC"); + strcat(path, "\\"); + strcat(path, cddaPath); - DWORD fa = GetFileAttributes(music_path); + DWORD fa = GetFileAttributes(path); if (fa != INVALID_FILE_ATTRIBUTES && fa & FILE_ATTRIBUTE_DIRECTORY) { - dprintf("ogg-winmm music directory is %s\n", music_path); + dprintf("ogg-winmm music directory is %s\n", path); memset(tracks, 0, sizeof(tracks)); unsigned int position = 0; for (int i = 1; i <= MAX_TRACKS; i++) { - snprintf(tracks[i].path, MAX_PATH, "%s\\Track%02d.ogg", music_path, i); + snprintf(tracks[i].path, MAX_PATH, "%s\\Track%02d.ogg", path, i); tracks[i].position = position; tracks[i].length = plr_length(tracks[i].path); diff --git a/resource/winmm.ini b/resource/winmm.ini index dcb5466..87aebf5 100644 --- a/resource/winmm.ini +++ b/resource/winmm.ini @@ -1,8 +1,12 @@ -; Volume override range: Integer [0, 100]. 0: Mute; 100: Max; -; If you change any value when game is running, you need to restart the game. -; NOTE: All volumes are capped by Windows system master volume control. +; If you change any value below when game is running, you need to restart the game for the change to take effect. [OGG-WinMM] +; The folder name to read CDDA tracks (OGG files) from. +; NOTE: This must be a path relative to the DLL itself. +CDDAPath = Music + +; Volume override for CDDA/MIDI/WAVE respectively. Range: Integer [0, 100]. 0: Mute; 100: Max. +; NOTE: All volumes are capped by Windows system master volume control. CDDAVolume = 100 MIDIVolume = 100 WAVEVolume = 100