author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9111 | 48ce04029fe4 |
child 10301 | 76966696a338 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
7170
diff
changeset
|
3 |
/** @file os2_m.cpp Music playback on OS/2. */ |
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
7170
diff
changeset
|
4 |
|
2189
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
5 |
#include "../stdafx.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
6 |
#include "../openttd.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
7 |
#include "os2_m.h" |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
8 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
9 |
#define INCL_DOS |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
10 |
#define INCL_OS2MM |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
11 |
#define INCL_WIN |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
12 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
13 |
#include <stdarg.h> |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
14 |
#include <os2.h> |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
15 |
#include <os2me.h> |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
16 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
17 |
/********************** |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
18 |
* OS/2 MIDI PLAYER |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
19 |
**********************/ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
20 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
21 |
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API, |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
22 |
* eh? Anyone would think they both came from the same place originally! ;) |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
23 |
*/ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
24 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
25 |
static long CDECL MidiSendCommand(const char *cmd, ...) |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
26 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
27 |
va_list va; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
28 |
char buf[512]; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
29 |
va_start(va, cmd); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
30 |
vsprintf(buf, cmd, va); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
31 |
va_end(va); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
32 |
return mciSendString(buf, NULL, 0, NULL, 0); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
33 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
34 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
35 |
static FMusicDriver_OS2 iFMusicDriver_OS2; |
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
36 |
|
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
37 |
void MusicDriver_OS2::PlaySong(const char *filename) |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
38 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
39 |
MidiSendCommand("close all"); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
40 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
41 |
if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
42 |
return; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
43 |
|
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
44 |
MidiSendCommand("play song from 0"); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
45 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
46 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
47 |
void MusicDriver_OS2::StopSong() |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
48 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
49 |
MidiSendCommand("close all"); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
50 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
51 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
52 |
void MusicDriver_OS2::SetVolume(byte vol) |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
53 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
54 |
MidiSendCommand("set song audio volume %d", ((vol/127)*100)); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
55 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
56 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
57 |
bool MusicDriver_OS2::IsSongPlaying() |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
58 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
59 |
char buf[16]; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
60 |
mciSendString("status song mode", buf, sizeof(buf), NULL, 0); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
61 |
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
62 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
63 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
64 |
const char *MusicDriver_OS2::Start(const char * const *parm) |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
65 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
66 |
return 0; |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
67 |
} |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
68 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
69 |
void MusicDriver_OS2::Stop() |
2175
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
70 |
{ |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
71 |
MidiSendCommand("close all"); |
06415cf75dc1
(svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff
changeset
|
72 |
} |