os2_m.cpp

00001 /* $Id: os2_m.cpp 10444 2007-07-05 12:23:54Z peter1138 $ */
00002 
00003 #include "../stdafx.h"
00004 #include "../openttd.h"
00005 #include "os2_m.h"
00006 
00007 #define INCL_DOS
00008 #define INCL_OS2MM
00009 #define INCL_WIN
00010 
00011 #include <stdarg.h>
00012 #include <os2.h>
00013 #include <os2me.h>
00014 
00015 /**********************
00016  * OS/2 MIDI PLAYER
00017  **********************/
00018 
00019 /* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
00020  * eh? Anyone would think they both came from the same place originally! ;)
00021  */
00022 
00023 static long CDECL MidiSendCommand(const char *cmd, ...)
00024 {
00025   va_list va;
00026   char buf[512];
00027   va_start(va, cmd);
00028   vsprintf(buf, cmd, va);
00029   va_end(va);
00030   return mciSendString(buf, NULL, 0, NULL, 0);
00031 }
00032 
00033 static FMusicDriver_OS2 iFMusicDriver_OS2;
00034 
00035 void MusicDriver_OS2::PlaySong(const char *filename)
00036 {
00037   MidiSendCommand("close all");
00038 
00039   if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
00040     return;
00041 
00042   MidiSendCommand("play song from 0");
00043 }
00044 
00045 void MusicDriver_OS2::StopSong()
00046 {
00047   MidiSendCommand("close all");
00048 }
00049 
00050 void MusicDriver_OS2::SetVolume(byte vol)
00051 {
00052   MidiSendCommand("set song audio volume %d", ((vol/127)*100));
00053 }
00054 
00055 bool MusicDriver_OS2::IsSongPlaying()
00056 {
00057   char buf[16];
00058   mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
00059   return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
00060 }
00061 
00062 const char *MusicDriver_OS2::Start(const char * const *parm)
00063 {
00064   return 0;
00065 }
00066 
00067 void MusicDriver_OS2::Stop()
00068 {
00069   MidiSendCommand("close all");
00070 }

Generated on Mon Sep 22 20:34:16 2008 for openttd by  doxygen 1.5.6