src/music/os2_m.cpp
branchnoai
changeset 9631 8a2d1c2ceb88
parent 6573 7624f942237f
child 10429 1b99254f9607
equal deleted inserted replaced
9630:550db5cefcc2 9631:8a2d1c2ceb88
    28 	vsprintf(buf, cmd, va);
    28 	vsprintf(buf, cmd, va);
    29 	va_end(va);
    29 	va_end(va);
    30 	return mciSendString(buf, NULL, 0, NULL, 0);
    30 	return mciSendString(buf, NULL, 0, NULL, 0);
    31 }
    31 }
    32 
    32 
    33 static void OS2MidiPlaySong(const char *filename)
    33 static FMusicDriver_OS2 iFMusicDriver_OS2;
       
    34 
       
    35 void MusicDriver_OS2::PlaySong(const char *filename)
    34 {
    36 {
    35 	MidiSendCommand("close all");
    37 	MidiSendCommand("close all");
    36 
    38 
    37 	if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
    39 	if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
    38 		return;
    40 		return;
    39 
    41 
    40 	MidiSendCommand("play song from 0");
    42 	MidiSendCommand("play song from 0");
    41 }
    43 }
    42 
    44 
    43 static void OS2MidiStopSong()
    45 void MusicDriver_OS2::StopSong()
    44 {
    46 {
    45 	MidiSendCommand("close all");
    47 	MidiSendCommand("close all");
    46 }
    48 }
    47 
    49 
    48 static void OS2MidiSetVolume(byte vol)
    50 void MusicDriver_OS2::SetVolume(byte vol)
    49 {
    51 {
    50 	MidiSendCommand("set song audio volume %d", ((vol/127)*100));
    52 	MidiSendCommand("set song audio volume %d", ((vol/127)*100));
    51 }
    53 }
    52 
    54 
    53 static bool OS2MidiIsSongPlaying()
    55 bool MusicDriver_OS2::IsSongPlaying()
    54 {
    56 {
    55 	char buf[16];
    57 	char buf[16];
    56 	mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
    58 	mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
    57 	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
    59 	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
    58 }
    60 }
    59 
    61 
    60 static const char *OS2MidiStart(const char * const *parm)
    62 const char *MusicDriver_OS2::Start(const char * const *parm)
    61 {
    63 {
    62 	return 0;
    64 	return 0;
    63 }
    65 }
    64 
    66 
    65 static void OS2MidiStop()
    67 void MusicDriver_OS2::Stop()
    66 {
    68 {
    67 	MidiSendCommand("close all");
    69 	MidiSendCommand("close all");
    68 }
    70 }
    69 
       
    70 const HalMusicDriver _os2_music_driver = {
       
    71 	OS2MidiStart,
       
    72 	OS2MidiStop,
       
    73 	OS2MidiPlaySong,
       
    74 	OS2MidiStopSong,
       
    75 	OS2MidiIsSongPlaying,
       
    76 	OS2MidiSetVolume,
       
    77 };