Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "../openttd.h"
00014 #include "os2_m.h"
00015
00016 #define INCL_DOS
00017 #define INCL_OS2MM
00018 #define INCL_WIN
00019
00020 #include <stdarg.h>
00021 #include <os2.h>
00022 #include <os2me.h>
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 static long CDECL MidiSendCommand(const char *cmd, ...)
00033 {
00034 va_list va;
00035 char buf[512];
00036 va_start(va, cmd);
00037 vseprintf(buf, lastof(buf), cmd, va);
00038 va_end(va);
00039 return mciSendString(buf, NULL, 0, NULL, 0);
00040 }
00041
00042 static FMusicDriver_OS2 iFMusicDriver_OS2;
00043
00044 void MusicDriver_OS2::PlaySong(const char *filename)
00045 {
00046 MidiSendCommand("close all");
00047
00048 if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) {
00049 return;
00050 }
00051
00052 MidiSendCommand("play song from 0");
00053 }
00054
00055 void MusicDriver_OS2::StopSong()
00056 {
00057 MidiSendCommand("close all");
00058 }
00059
00060 void MusicDriver_OS2::SetVolume(byte vol)
00061 {
00062 MidiSendCommand("set song audio volume %d", ((vol/127)*100));
00063 }
00064
00065 bool MusicDriver_OS2::IsSongPlaying()
00066 {
00067 char buf[16];
00068 mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
00069 return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
00070 }
00071
00072 const char *MusicDriver_OS2::Start(const char * const *parm)
00073 {
00074 return 0;
00075 }
00076
00077 void MusicDriver_OS2::Stop()
00078 {
00079 MidiSendCommand("close all");
00080 }