1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* $Id$ */
/*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file os2_m.cpp Music playback on OS/2. */
#include "../stdafx.h"
#include "../openttd.h"
#include "os2_m.h"
#include "../base_media_base.h"
#define INCL_DOS
#define INCL_OS2MM
#define INCL_WIN
#include <stdarg.h>
#include <os2.h>
#include <os2me.h>
#include "../safeguards.h"
/**********************
* OS/2 MIDI PLAYER
**********************/
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
* eh? Anyone would think they both came from the same place originally! ;)
*/
/**
* Send a midi command.
* @param cmd The command to send.
* @return The result of sending it.
*/
static long CDECL MidiSendCommand(const char *cmd, ...)
{
va_list va;
char buf[512];
va_start(va, cmd);
vseprintf(buf, lastof(buf), cmd, va);
va_end(va);
return mciSendString(buf, NULL, 0, NULL, 0);
}
/** OS/2's music player's factory. */
static FMusicDriver_OS2 iFMusicDriver_OS2;
void MusicDriver_OS2::PlaySong(const MusicSongInfo &song)
{
if (song.filetype != MTT_STANDARDMIDI) return;
MidiSendCommand("close all");
if (MidiSendCommand("open %s type sequencer alias song", song.filename) != 0) {
return;
}
MidiSendCommand("play song from 0");
}
void MusicDriver_OS2::StopSong()
{
MidiSendCommand("close all");
}
void MusicDriver_OS2::SetVolume(byte vol)
{
MidiSendCommand("set song audio volume %d", ((vol/127)*100));
}
bool MusicDriver_OS2::IsSongPlaying()
{
char buf[16];
mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
}
const char *MusicDriver_OS2::Start(const char * const *parm)
{
return 0;
}
void MusicDriver_OS2::Stop()
{
MidiSendCommand("close all");
}
|