src/music/os2_m.cpp
author celestar
Mon, 19 Mar 2007 12:38:16 +0000
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 5835 e0ff603ae0b7
child 6720 35756db7e577
permissions -rw-r--r--
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2175
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2175
diff changeset
     2
2189
d240b9097139 (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
     3
#include "../stdafx.h"
d240b9097139 (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
     4
#include "../openttd.h"
d240b9097139 (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 "os2_m.h"
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     6
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     7
#define INCL_DOS
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     8
#define INCL_OS2MM
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     9
#define INCL_WIN
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    10
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    11
#include <stdarg.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    12
#include <os2.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    13
#include <os2me.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    14
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    15
/**********************
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    16
 * OS/2 MIDI PLAYER
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    17
 **********************/
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    18
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    19
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    20
 * eh? Anyone would think they both came from the same place originally! ;)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    21
 */
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    22
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    23
static long CDECL MidiSendCommand(const char *cmd, ...)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    24
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    25
	va_list va;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    26
	char buf[512];
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    27
	va_start(va, cmd);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    28
	vsprintf(buf, cmd, va);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    29
	va_end(va);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    30
	return mciSendString(buf, NULL, 0, NULL, 0);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    31
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    32
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    33
static void OS2MidiPlaySong(const char *filename)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    34
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    35
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    36
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    37
	if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    38
		return;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    39
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    40
	MidiSendCommand("play song from 0");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    41
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    42
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 5835
diff changeset
    43
static void OS2MidiStopSong()
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    44
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    45
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    46
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    47
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    48
static void OS2MidiSetVolume(byte vol)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    49
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    50
	MidiSendCommand("set song audio volume %d", ((vol/127)*100));
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    51
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    52
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 5835
diff changeset
    53
static bool OS2MidiIsSongPlaying()
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    54
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    55
	char buf[16];
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    56
	mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    57
	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    58
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    59
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    60
static const char *OS2MidiStart(const char * const *parm)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    61
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    62
	return 0;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    63
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    64
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 5835
diff changeset
    65
static void OS2MidiStop()
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    66
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    67
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    68
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    69
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    70
const HalMusicDriver _os2_music_driver = {
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    71
	OS2MidiStart,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    72
	OS2MidiStop,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    73
	OS2MidiPlaySong,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    74
	OS2MidiStopSong,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    75
	OS2MidiIsSongPlaying,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    76
	OS2MidiSetVolume,
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    77
};