Skip to content

Commit

Permalink
Add an option to customize the music folder name.
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuanx committed Oct 24, 2024
1 parent 5f93437 commit a7f3e78
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 14 additions & 11 deletions ogg-winmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down
10 changes: 7 additions & 3 deletions resource/winmm.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a7f3e78

Please sign in to comment.