44 { |
44 { |
45 _midi.new_vol = vol; |
45 _midi.new_vol = vol; |
46 SetEvent(_midi.wait_obj); |
46 SetEvent(_midi.wait_obj); |
47 } |
47 } |
48 |
48 |
49 static MCIERROR CDECL MidiSendCommand(const char* cmd, ...) |
49 static MCIERROR CDECL MidiSendCommand(const TCHAR* cmd, ...) |
50 { |
50 { |
51 va_list va; |
51 va_list va; |
52 char buf[512]; |
52 TCHAR buf[512]; |
53 |
53 |
54 va_start(va, cmd); |
54 va_start(va, cmd); |
55 vsnprintf(buf, lengthof(buf), cmd, va); |
55 _vsntprintf(buf, lengthof(buf), cmd, va); |
56 va_end(va); |
56 va_end(va); |
57 return mciSendStringA(buf, NULL, 0, 0); |
57 return mciSendString(buf, NULL, 0, 0); |
58 } |
58 } |
59 |
59 |
60 static bool MidiIntPlaySong(const char *filename) |
60 static bool MidiIntPlaySong(const char *filename) |
61 { |
61 { |
62 MidiSendCommand("close all"); |
62 MidiSendCommand(_T("close all")); |
63 if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false; |
|
64 |
63 |
65 return MidiSendCommand("play song from 0") == 0; |
64 if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), OTTD2FS(filename)) != 0) { |
|
65 /* Let's try the "short name" */ |
|
66 TCHAR buf[MAX_PATH]; |
|
67 if (GetShortPathName(OTTD2FS(filename), buf, MAX_PATH) == 0) return false; |
|
68 if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), buf) != 0) return false; |
|
69 } |
|
70 |
|
71 return MidiSendCommand(_T("play song from 0")) == 0; |
66 } |
72 } |
67 |
73 |
68 static void MidiIntStopSong() |
74 static void MidiIntStopSong() |
69 { |
75 { |
70 MidiSendCommand("close all"); |
76 MidiSendCommand(_T("close all")); |
71 } |
77 } |
72 |
78 |
73 static void MidiIntSetVolume(int vol) |
79 static void MidiIntSetVolume(int vol) |
74 { |
80 { |
75 DWORD v = (vol * 65535 / 127); |
81 DWORD v = (vol * 65535 / 127); |