os2_m.cpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
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  * OS/2 MIDI PLAYER
00026  **********************/
00027 
00028 /* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
00029  * eh? Anyone would think they both came from the same place originally! ;)
00030  */
00031 
00037 static long CDECL MidiSendCommand(const char *cmd, ...)
00038 {
00039   va_list va;
00040   char buf[512];
00041   va_start(va, cmd);
00042   vseprintf(buf, lastof(buf), cmd, va);
00043   va_end(va);
00044   return mciSendString(buf, NULL, 0, NULL, 0);
00045 }
00046 
00048 static FMusicDriver_OS2 iFMusicDriver_OS2;
00049 
00050 void MusicDriver_OS2::PlaySong(const char *filename)
00051 {
00052   MidiSendCommand("close all");
00053 
00054   if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) {
00055     return;
00056   }
00057 
00058   MidiSendCommand("play song from 0");
00059 }
00060 
00061 void MusicDriver_OS2::StopSong()
00062 {
00063   MidiSendCommand("close all");
00064 }
00065 
00066 void MusicDriver_OS2::SetVolume(byte vol)
00067 {
00068   MidiSendCommand("set song audio volume %d", ((vol/127)*100));
00069 }
00070 
00071 bool MusicDriver_OS2::IsSongPlaying()
00072 {
00073   char buf[16];
00074   mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
00075   return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
00076 }
00077 
00078 const char *MusicDriver_OS2::Start(const char * const *parm)
00079 {
00080   return 0;
00081 }
00082 
00083 void MusicDriver_OS2::Stop()
00084 {
00085   MidiSendCommand("close all");
00086 }

Generated on Mon May 9 05:18:54 2011 for OpenTTD by  doxygen 1.6.1