tron@2186: /* $Id$ */ tron@2186: tron@2189: #include "../stdafx.h" tron@2189: #include "../openttd.h" tron@2189: #include "os2_m.h" orudge@2175: orudge@2175: #define INCL_DOS orudge@2175: #define INCL_OS2MM orudge@2175: #define INCL_WIN orudge@2175: orudge@2175: #include orudge@2175: #include orudge@2175: #include orudge@2175: orudge@2175: /********************** orudge@2175: * OS/2 MIDI PLAYER orudge@2175: **********************/ orudge@2175: orudge@2175: /* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API, orudge@2175: * eh? Anyone would think they both came from the same place originally! ;) orudge@2175: */ orudge@2175: orudge@2175: static long CDECL MidiSendCommand(const char *cmd, ...) orudge@2175: { orudge@2175: va_list va; orudge@2175: char buf[512]; orudge@2175: va_start(va, cmd); orudge@2175: vsprintf(buf, cmd, va); orudge@2175: va_end(va); orudge@2175: return mciSendString(buf, NULL, 0, NULL, 0); orudge@2175: } orudge@2175: orudge@2175: static void OS2MidiPlaySong(const char *filename) orudge@2175: { orudge@2175: MidiSendCommand("close all"); orudge@2175: orudge@2175: if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) orudge@2175: return; orudge@2175: orudge@2175: MidiSendCommand("play song from 0"); orudge@2175: } orudge@2175: orudge@2175: static void OS2MidiStopSong(void) orudge@2175: { orudge@2175: MidiSendCommand("close all"); orudge@2175: } orudge@2175: orudge@2175: static void OS2MidiSetVolume(byte vol) orudge@2175: { orudge@2175: MidiSendCommand("set song audio volume %d", ((vol/127)*100)); orudge@2175: } orudge@2175: orudge@2175: static bool OS2MidiIsSongPlaying(void) orudge@2175: { orudge@2175: char buf[16]; orudge@2175: mciSendString("status song mode", buf, sizeof(buf), NULL, 0); orudge@2175: return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; orudge@2175: } orudge@2175: orudge@2175: static const char *OS2MidiStart(const char * const *parm) orudge@2175: { orudge@2175: return 0; orudge@2175: } orudge@2175: orudge@2175: static void OS2MidiStop(void) orudge@2175: { orudge@2175: MidiSendCommand("close all"); orudge@2175: } orudge@2175: orudge@2175: const HalMusicDriver _os2_music_driver = { orudge@2175: OS2MidiStart, orudge@2175: OS2MidiStop, orudge@2175: OS2MidiPlaySong, orudge@2175: OS2MidiStopSong, orudge@2175: OS2MidiIsSongPlaying, orudge@2175: OS2MidiSetVolume, orudge@2175: };