music/os2_m.c
author Darkvater
Thu, 02 Mar 2006 02:22:15 +0000
changeset 3121 2e50f731567a
parent 2548 97ada3bd2702
permissions -rw-r--r--
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
- Remove the temporary synchronisation in during the map-transfer as this is no longer needed
- The saved patches work just like the saved gameoptions. You have a _patches and a _patches_newgame struct. The _patches_newgame struct contains the values from the configuration file and thus the defaults for new games. When a new game is started or an older game is loaded, the default values are copied over to _patches to be used. When you load a game that has PATS saved, the default values are also loaded, but immediately overwritten by the values from the savegame. This ensures that player-based values are always taken from your personal preferences.
- The current implementation also changes the default values if you change player-based settings in the game. For example changing window_snap_radius in a certain game will also change it for all next OpenTTD sessions.
- The savegame version has been increased to 22.
- The last 6 orso patches close the following reports:
[ 1366446 ] different names for patches: all patch settings have the same name as in the configuration file and are reachable from the console.
[ 1288024 ] Strange string on OTTD initial screen: configuration (and this includes patches) inputs are validated and clamped to their minimum/maximum values.
[ 1423198 ] Make "Signals on Drive side" player, not server, based: this is only visual so current setting is to save it with the savegame but not synchronise in multiplayer.
[ 1208070 ] Patches and New GRF options saved: apart from newgrf this is done
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
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    43
static void OS2MidiStopSong(void)
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
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    53
static bool OS2MidiIsSongPlaying(void)
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
c29911d0d400 (svn r2689) - Split OS/2 music driver into os2_m.c, update project file
orudge
parents:
diff changeset
    65
static void OS2MidiStop(void)
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
};