diff --git a/music/os2_m.c b/music/os2_m.c new file mode 100644 --- /dev/null +++ b/music/os2_m.c @@ -0,0 +1,76 @@ +#include "stdafx.h" +#include "openttd.h" +#include "music/os2_m.h" + +#define INCL_DOS +#define INCL_OS2MM +#define INCL_WIN + +#include +#include +#include + +/********************** + * OS/2 MIDI PLAYER + **********************/ + +/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API, + * eh? Anyone would think they both came from the same place originally! ;) + */ + +static long CDECL MidiSendCommand(const char *cmd, ...) +{ + va_list va; + char buf[512]; + va_start(va, cmd); + vsprintf(buf, cmd, va); + va_end(va); + return mciSendString(buf, NULL, 0, NULL, 0); +} + +static void OS2MidiPlaySong(const char *filename) +{ + MidiSendCommand("close all"); + + if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) + return; + + MidiSendCommand("play song from 0"); +} + +static void OS2MidiStopSong(void) +{ + MidiSendCommand("close all"); +} + +static void OS2MidiSetVolume(byte vol) +{ + MidiSendCommand("set song audio volume %d", ((vol/127)*100)); +} + +static bool OS2MidiIsSongPlaying(void) +{ + char buf[16]; + mciSendString("status song mode", buf, sizeof(buf), NULL, 0); + return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; +} + +static const char *OS2MidiStart(const char * const *parm) +{ + return 0; +} + +static void OS2MidiStop(void) +{ + MidiSendCommand("close all"); +} + +const HalMusicDriver _os2_music_driver = { + OS2MidiStart, + OS2MidiStop, + OS2MidiPlaySong, + OS2MidiStopSong, + OS2MidiIsSongPlaying, + OS2MidiSetVolume, +}; + diff --git a/music/os2_m.h b/music/os2_m.h new file mode 100644 --- /dev/null +++ b/music/os2_m.h @@ -0,0 +1,8 @@ +#ifndef MUSIC_OS2_H +#define MUSIC_OS2_H + +#include "hal.h" + +extern const HalMusicDriver _os2_music_driver; + +#endif diff --git a/openttd.tgt b/openttd.tgt --- a/openttd.tgt +++ b/openttd.tgt @@ -194,7 +194,7 @@ 1 0 51 WPickList -107 +114 52 MItem 3 @@ -789,8 +789,8 @@ 1 0 189 MItem -12 -dummy_land.c +8 +driver.c 190 WString 4 @@ -807,8 +807,8 @@ 1 0 193 MItem -9 -economy.c +12 +dummy_land.c 194 WString 4 @@ -825,8 +825,8 @@ 1 0 197 MItem -8 -engine.c +9 +economy.c 198 WString 4 @@ -843,8 +843,8 @@ 1 0 201 MItem -12 -engine_gui.c +8 +engine.c 202 WString 4 @@ -861,8 +861,8 @@ 1 0 205 MItem -8 -fileio.c +12 +engine_gui.c 206 WString 4 @@ -879,8 +879,8 @@ 1 0 209 MItem -5 -gfx.c +8 +fileio.c 210 WString 4 @@ -897,8 +897,8 @@ 1 0 213 MItem -11 -graph_gui.c +5 +gfx.c 214 WString 4 @@ -915,8 +915,8 @@ 1 0 217 MItem -14 -industry_cmd.c +11 +graph_gui.c 218 WString 4 @@ -934,7 +934,7 @@ 0 221 MItem 14 -industry_gui.c +industry_cmd.c 222 WString 4 @@ -951,8 +951,8 @@ 1 0 225 MItem -11 -intro_gui.c +14 +industry_gui.c 226 WString 4 @@ -970,7 +970,7 @@ 0 229 MItem 11 -landscape.c +intro_gui.c 230 WString 4 @@ -987,8 +987,8 @@ 1 0 233 MItem -10 -main_gui.c +11 +landscape.c 234 WString 4 @@ -1005,8 +1005,8 @@ 1 0 237 MItem -5 -map.c +10 +main_gui.c 238 WString 4 @@ -1024,7 +1024,7 @@ 0 241 MItem 5 -md5.c +map.c 242 WString 4 @@ -1041,8 +1041,8 @@ 1 0 245 MItem -9 -minilzo.c +5 +md5.c 246 WString 4 @@ -1059,8 +1059,8 @@ 1 0 249 MItem -6 -misc.c +9 +minilzo.c 250 WString 4 @@ -1077,8 +1077,8 @@ 1 0 253 MItem -10 -misc_cmd.c +6 +misc.c 254 WString 4 @@ -1096,7 +1096,7 @@ 0 257 MItem 10 -misc_gui.c +misc_cmd.c 258 WString 4 @@ -1113,8 +1113,8 @@ 1 0 261 MItem -7 -mixer.c +10 +misc_gui.c 262 WString 4 @@ -1131,8 +1131,8 @@ 1 0 265 MItem -11 -music_gui.c +7 +mixer.c 266 WString 4 @@ -1149,8 +1149,8 @@ 1 0 269 MItem -9 -namegen.c +14 +music\null_m.c 270 WString 4 @@ -1167,8 +1167,8 @@ 1 0 273 MItem -9 -network.c +13 +music\os2_m.c 274 WString 4 @@ -1185,8 +1185,8 @@ 1 0 277 MItem -16 -network_client.c +11 +music_gui.c 278 WString 4 @@ -1203,8 +1203,8 @@ 1 0 281 MItem -14 -network_data.c +9 +namegen.c 282 WString 4 @@ -1221,8 +1221,8 @@ 1 0 285 MItem -18 -network_gamelist.c +9 +network.c 286 WString 4 @@ -1239,8 +1239,8 @@ 1 0 289 MItem -13 -network_gui.c +16 +network_client.c 290 WString 4 @@ -1257,8 +1257,8 @@ 1 0 293 MItem -16 -network_server.c +14 +network_data.c 294 WString 4 @@ -1275,8 +1275,8 @@ 1 0 297 MItem -13 -network_udp.c +18 +network_gamelist.c 298 WString 4 @@ -1293,8 +1293,8 @@ 1 0 301 MItem -8 -newgrf.c +13 +network_gui.c 302 WString 4 @@ -1311,8 +1311,8 @@ 1 0 305 MItem -10 -news_gui.c +16 +network_server.c 306 WString 4 @@ -1329,8 +1329,8 @@ 1 0 309 MItem -5 -npf.c +13 +network_udp.c 310 WString 4 @@ -1347,8 +1347,8 @@ 1 0 313 MItem -11 -oldloader.c +8 +newgrf.c 314 WString 4 @@ -1365,8 +1365,8 @@ 1 0 317 MItem -9 -openttd.c +10 +news_gui.c 318 WString 4 @@ -1383,8 +1383,8 @@ 1 0 321 MItem -11 -order_cmd.c +5 +npf.c 322 WString 4 @@ -1402,7 +1402,7 @@ 0 325 MItem 11 -order_gui.c +oldloader.c 326 WString 4 @@ -1419,8 +1419,8 @@ 1 0 329 MItem -5 -os2.c +9 +openttd.c 330 WString 4 @@ -1437,8 +1437,8 @@ 1 0 333 MItem -10 -pathfind.c +11 +order_cmd.c 334 WString 4 @@ -1455,8 +1455,8 @@ 1 0 337 MItem -5 -pbs.c +11 +order_gui.c 338 WString 4 @@ -1473,8 +1473,8 @@ 1 0 341 MItem -12 -player_gui.c +5 +os2.c 342 WString 4 @@ -1491,8 +1491,8 @@ 1 0 345 MItem -9 -players.c +10 +pathfind.c 346 WString 4 @@ -1509,8 +1509,8 @@ 1 0 349 MItem -6 -pool.c +5 +pbs.c 350 WString 4 @@ -1527,8 +1527,8 @@ 1 0 353 MItem -7 -queue.c +12 +player_gui.c 354 WString 4 @@ -1545,8 +1545,8 @@ 1 0 357 MItem -6 -rail.c +9 +players.c 358 WString 4 @@ -1563,8 +1563,8 @@ 1 0 361 MItem -10 -rail_cmd.c +6 +pool.c 362 WString 4 @@ -1581,8 +1581,8 @@ 1 0 365 MItem -10 -rail_gui.c +7 +queue.c 366 WString 4 @@ -1599,8 +1599,8 @@ 1 0 369 MItem -5 -rev.c +6 +rail.c 370 WString 4 @@ -1610,67 +1610,67 @@ WVList 0 372 WVList +0 +52 1 +1 +0 373 -ActionStates +MItem +10 +rail_cmd.c 374 WString -5 -&Make +4 +COBJ 375 WVList 0 +376 +WVList +0 52 1 1 0 -376 +377 MItem 10 -road_cmd.c -377 +rail_gui.c +378 WString 4 COBJ -378 +379 WVList 0 -379 +380 WVList 0 52 1 1 0 -380 +381 MItem -10 -road_gui.c -381 +5 +rev.c +382 WString 4 COBJ -382 -WVList -0 383 WVList 0 -52 -1 +384 +WVList 1 -0 -384 -MItem -13 -roadveh_cmd.c 385 +ActionStates +386 WString -4 -COBJ -386 -WVList -0 +5 +&Make 387 WVList 0 @@ -1680,8 +1680,8 @@ 1 0 388 MItem -13 -roadveh_gui.c +10 +road_cmd.c 389 WString 4 @@ -1699,7 +1699,7 @@ 0 392 MItem 10 -saveload.c +road_gui.c 393 WString 4 @@ -1716,8 +1716,8 @@ 1 0 396 MItem -12 -screenshot.c +13 +roadveh_cmd.c 397 WString 4 @@ -1734,8 +1734,8 @@ 1 0 400 MItem -5 -sdl.c +13 +roadveh_gui.c 401 WString 4 @@ -1753,7 +1753,7 @@ 0 404 MItem 10 -settings.c +saveload.c 405 WString 4 @@ -1770,8 +1770,8 @@ 1 0 408 MItem -14 -settings_gui.c +12 +screenshot.c 409 WString 4 @@ -1788,8 +1788,8 @@ 1 0 412 MItem -10 -ship_cmd.c +5 +sdl.c 413 WString 4 @@ -1807,7 +1807,7 @@ 0 416 MItem 10 -ship_gui.c +settings.c 417 WString 4 @@ -1824,8 +1824,8 @@ 1 0 420 MItem -7 -signs.c +14 +settings_gui.c 421 WString 4 @@ -1842,8 +1842,8 @@ 1 0 424 MItem -14 -smallmap_gui.c +10 +ship_cmd.c 425 WString 4 @@ -1860,8 +1860,8 @@ 1 0 428 MItem -7 -sound.c +10 +ship_gui.c 429 WString 4 @@ -1878,8 +1878,8 @@ 1 0 432 MItem -8 -sprite.c +7 +signs.c 433 WString 4 @@ -1896,8 +1896,8 @@ 1 0 436 MItem -13 -spritecache.c +14 +smallmap_gui.c 437 WString 4 @@ -1914,8 +1914,8 @@ 1 0 440 MItem -13 -station_cmd.c +7 +sound.c 441 WString 4 @@ -1932,8 +1932,8 @@ 1 0 444 MItem -13 -station_gui.c +14 +sound\null_s.c 445 WString 4 @@ -1950,8 +1950,8 @@ 1 0 448 MItem -8 -StdAfx.c +13 +sound\sdl_s.c 449 WString 4 @@ -1969,7 +1969,7 @@ 0 452 MItem 8 -string.c +sprite.c 453 WString 4 @@ -1986,8 +1986,8 @@ 1 0 456 MItem -9 -strings.c +13 +spritecache.c 457 WString 4 @@ -2005,7 +2005,7 @@ 0 460 MItem 13 -subsidy_gui.c +station_cmd.c 461 WString 4 @@ -2022,8 +2022,8 @@ 1 0 464 MItem -15 -terraform_gui.c +13 +station_gui.c 465 WString 4 @@ -2040,8 +2040,8 @@ 1 0 468 MItem -9 -texteff.c +8 +StdAfx.c 469 WString 4 @@ -2058,8 +2058,8 @@ 1 0 472 MItem -6 -tile.c +8 +string.c 473 WString 4 @@ -2076,8 +2076,8 @@ 1 0 476 MItem -10 -town_cmd.c +9 +strings.c 477 WString 4 @@ -2094,8 +2094,8 @@ 1 0 480 MItem -10 -town_gui.c +13 +subsidy_gui.c 481 WString 4 @@ -2112,8 +2112,8 @@ 1 0 484 MItem -11 -train_cmd.c +15 +terraform_gui.c 485 WString 4 @@ -2130,8 +2130,8 @@ 1 0 488 MItem -11 -train_gui.c +9 +texteff.c 489 WString 4 @@ -2148,8 +2148,8 @@ 1 0 492 MItem -10 -tree_cmd.c +6 +tile.c 493 WString 4 @@ -2166,8 +2166,8 @@ 1 0 496 MItem -18 -tunnelbridge_cmd.c +10 +town_cmd.c 497 WString 4 @@ -2184,8 +2184,8 @@ 1 0 500 MItem -15 -unmovable_cmd.c +10 +town_gui.c 501 WString 4 @@ -2202,8 +2202,8 @@ 1 0 504 MItem -9 -vehicle.c +11 +train_cmd.c 505 WString 4 @@ -2220,8 +2220,8 @@ 1 0 508 MItem -13 -vehicle_gui.c +11 +train_gui.c 509 WString 4 @@ -2239,7 +2239,7 @@ 0 512 MItem 10 -viewport.c +tree_cmd.c 513 WString 4 @@ -2256,8 +2256,8 @@ 1 0 516 MItem -11 -water_cmd.c +18 +tunnelbridge_cmd.c 517 WString 4 @@ -2274,8 +2274,8 @@ 1 0 520 MItem -10 -waypoint.c +15 +unmovable_cmd.c 521 WString 4 @@ -2292,8 +2292,8 @@ 1 0 524 MItem -8 -widget.c +9 +vehicle.c 525 WString 4 @@ -2310,8 +2310,8 @@ 1 0 528 MItem -8 -window.c +13 +vehicle_gui.c 529 WString 4 @@ -2326,3 +2326,129 @@ 52 1 1 0 +532 +MItem +14 +video\null_v.c +533 +WString +4 +COBJ +534 +WVList +0 +535 +WVList +0 +52 +1 +1 +0 +536 +MItem +13 +video\sdl_v.c +537 +WString +4 +COBJ +538 +WVList +0 +539 +WVList +0 +52 +1 +1 +0 +540 +MItem +10 +viewport.c +541 +WString +4 +COBJ +542 +WVList +0 +543 +WVList +0 +52 +1 +1 +0 +544 +MItem +11 +water_cmd.c +545 +WString +4 +COBJ +546 +WVList +0 +547 +WVList +0 +52 +1 +1 +0 +548 +MItem +10 +waypoint.c +549 +WString +4 +COBJ +550 +WVList +0 +551 +WVList +0 +52 +1 +1 +0 +552 +MItem +8 +widget.c +553 +WString +4 +COBJ +554 +WVList +0 +555 +WVList +0 +52 +1 +1 +0 +556 +MItem +8 +window.c +557 +WString +4 +COBJ +558 +WVList +0 +559 +WVList +0 +52 +1 +1 +0 diff --git a/os/os2/openttd.wpj b/os/os2/openttd.wpj --- a/os/os2/openttd.wpj +++ b/os/os2/openttd.wpj @@ -44,7 +44,7 @@ WFileName 17 ..\..\openttd.tgt 0 -18 +22 11 VComponent 12 diff --git a/os2.c b/os2.c --- a/os2.c +++ b/os2.c @@ -35,6 +35,15 @@ #include #endif +#include "sound/null_s.h" +#include "sound/sdl_s.h" + +#include "video/null_v.h" +#include "video/sdl_v.h" + +#include "music/null_m.h" +#include "music/os2_m.h" + static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1, s2); @@ -635,70 +644,6 @@ void OS2_SwitchToConsoleMode(void) pib->pib_ultype = 3; } -/********************** - * OS/2 MIDI PLAYER - **********************/ - -/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API, - * eh? Anyone would think they both came from the same place originally! ;) - */ - -static long CDECL MidiSendCommand(const char *cmd, ...) -{ - va_list va; - char buf[512]; - va_start(va, cmd); - vsprintf(buf, cmd, va); - va_end(va); - return mciSendString(buf, NULL, 0, NULL, 0); -} - -static void OS2MidiPlaySong(const char *filename) -{ - MidiSendCommand("close all"); - - if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) - return; - - MidiSendCommand("play song from 0"); -} - -static void OS2MidiStopSong(void) -{ - MidiSendCommand("close all"); -} - -static void OS2MidiSetVolume(byte vol) -{ - MidiSendCommand("set song audio volume %d", ((vol/127)*100)); -} - -static bool OS2MidiIsSongPlaying(void) -{ - char buf[16]; - mciSendString("status song mode", buf, sizeof(buf), NULL, 0); - return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; -} - -static const char *OS2MidiStart(const char * const *parm) -{ - return 0; -} - -static void OS2MidiStop(void) -{ - MidiSendCommand("close all"); -} - -const HalMusicDriver _os2_music_driver = { - OS2MidiStart, - OS2MidiStop, - OS2MidiPlaySong, - OS2MidiStopSong, - OS2MidiIsSongPlaying, - OS2MidiSetVolume, -}; - /** * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard * and append this up to the maximum length (either absolute or screenlength). If maxlength