src/music/os2_m.cpp
author smatz
Sun, 15 Jun 2008 13:52:51 +0000
changeset 10966 3de9939c8a91
parent 10429 1b99254f9607
permissions -rw-r--r--
(svn r13520) -Fix (r13375): pointer has to be valid before it can be loaded to (SLE_STR)
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
10429
1b99254f9607 (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: 7666
diff changeset
     3
/** @file os2_m.cpp Music playback on OS/2. */
1b99254f9607 (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: 7666
diff changeset
     4
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
     5
#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
     6
#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
     7
#include "os2_m.h"
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     8
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
     9
#define INCL_DOS
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    10
#define INCL_OS2MM
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    11
#define INCL_WIN
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    12
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    13
#include <stdarg.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    14
#include <os2.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    15
#include <os2me.h>
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    16
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
 * OS/2 MIDI PLAYER
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    19
 **********************/
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    20
c29911d0d400 (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,
c29911d0d400 (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! ;)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    23
 */
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
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
    26
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    27
	va_list va;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    28
	char buf[512];
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    29
	va_start(va, cmd);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    30
	vsprintf(buf, cmd, va);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    31
	va_end(va);
c29911d0d400 (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);
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    33
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    34
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    35
static FMusicDriver_OS2 iFMusicDriver_OS2;
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    36
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    37
void MusicDriver_OS2::PlaySong(const char *filename)
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    38
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    39
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    40
c29911d0d400 (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)
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    42
		return;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    43
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    44
	MidiSendCommand("play song from 0");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    45
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    46
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    47
void MusicDriver_OS2::StopSong()
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    48
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    49
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    50
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    51
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    52
void MusicDriver_OS2::SetVolume(byte vol)
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    53
{
c29911d0d400 (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));
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    55
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    56
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    57
bool MusicDriver_OS2::IsSongPlaying()
2175
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
	char buf[16];
c29911d0d400 (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);
c29911d0d400 (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;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    62
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    63
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    64
const char *MusicDriver_OS2::Start(const char * const *parm)
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    65
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    66
	return 0;
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    67
}
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    68
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 6573
diff changeset
    69
void MusicDriver_OS2::Stop()
2175
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    70
{
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    71
	MidiSendCommand("close all");
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    72
}