(svn r1281) -Fix: the OS/2 is now finished. Fixes:

- Networking
  - File selector issue
  - Keyboard input
  - Dedicated server console issue (use dedicated.cmd to open a server)
  - Plus many other minor issues
This commit is contained in:
truelight 2004-12-27 10:40:04 +00:00
parent f3c8f40c51
commit 1f4c1e8821
13 changed files with 989 additions and 745 deletions

View File

@ -20,6 +20,8 @@
# include <unistd.h> # include <unistd.h>
# include <conio.h> # include <conio.h>
# define STDIN 0 /* file descriptor for standard input */ # define STDIN 0 /* file descriptor for standard input */
extern void OS2_SwitchToConsoleMode();
#endif #endif
#ifdef UNIX #ifdef UNIX
@ -100,6 +102,11 @@ static const char *DedicatedVideoStart(char **parm) {
SetConsoleTitle("OpenTTD Dedicated Server"); SetConsoleTitle("OpenTTD Dedicated Server");
#endif #endif
#ifdef __OS2__
// For OS/2 we also need to switch to console mode instead of PM mode
OS2_SwitchToConsoleMode();
#endif
DEBUG(misc,0)("Loading dedicated server..."); DEBUG(misc,0)("Loading dedicated server...");
return NULL; return NULL;
} }

View File

@ -1,48 +1,114 @@
OpenTTD: OS/2 version ** CURRENTLY INCOMPLETE ** OpenTTD: OS/2 version
===================== =====================
OpenTTD has been ported to work on OS/2 4.x or later (including eComStation). At the moment, it does not work properly, but it OpenTTD has been ported to work on OS/2 4.x or later (including
can compile and work to an extent. eComStation). The game should work as well as it does on Windows
or other platforms: the main issues you may encounter are graphics
card problems, but that is really the fault of SDL.
=========================
USING OPENTTD FOR OS/2
=========================
LIBRARIES REQUIRED FOR END USERS
--------------------------------
SDL.DLL (SDL 1.2.7) and FSLib.dll are required to use this program:
these can be downloaded from the Files section at
http://sourceforge.net/projects/openttd/ - see "os2-useful.zip".
Note that to actually play the game, I have found in my own
experience that a version of the Scitech Display Drivers or its later
incarnation (see www.scitech.com) are necessary for it to work. If
you have trouble with your native drivers, try the Scitech drivers
and see if they help the problem.
KNOWN ISSUES
------------
- If an error occurs during loading, the OS/2 error message window
is not always displayed.
A NOTE ABOUT MUSIC
------------------
OpenTTD includes a music driver which uses the MCI MIDI system. Unfortunately,
due to the lack of proper MIDI hardware myself, I have been unable to test it,
but during testing, I found that when MIDI was enabled, I got no sound
effects. I therefore decided to DISABLE music by default.
To enable music, start OpenTTD with the command line:
openttd -m os2
If I hear enough responses that both music and sound work together (it might
just be my system), I'll have the defaults changed.
A NOTE ABOUT DEDICATED MULTIPLAYER SERVERS
------------------------------------------
To start a dedicated multiplayer server, you should run the dedicated.cmd
file. This enables OpenTTD to open up a VIO console window to display
its output and gather any necessary input. Running "openttd -D"
directly will result in the console not being displayed. You may
still pass any other parameters ('-D' is already passed) to
dedicated.cmd.
=========================
BUILDING THE OS/2 VERSION
=========================
Compiler Compiler
-------- --------
Open Watcom 1.3 was used to build OpenTTD (earlier versions will NOT work). See http://www.openwatcom.org/ to download it. Open Watcom 1.3 was used to build OpenTTD (earlier versions will
It may also be possible to build OpenTTD under OS/2: I attempted this before using Open Watcom, but found the tools available NOT work). See http://www.openwatcom.org/ to download it. It may
for OS/2 at the time to be a bit more tricky to get working. also be possible to build OpenTTD under OS/2: I attempted this
before using Open Watcom, but found the tools available for OS/2
at the time to be a bit more tricky to get working.
Due to complexities in my set-up, I actually used the Win32 version of Open Watcom to initially compile OpenTTD for OS/2. There Due to complexities in my set-up, I actually used the Win32 version
should be no reason of course why the OS/2 version cannot be used. of Open Watcom to initially compile OpenTTD for OS/2. There should
be no reason of course why the OS/2 version cannot be used.
Libraries Required Libraries Required
------------------ ------------------
The following libraries are required. To build zlib and libpng, I simply added the required files (watch out for sample The following libraries are required. To build zlib and libpng, I
programs, etc) to an IDE project file and built a library: simply added the required files (watch out for sample programs, etc)
to an IDE project file and built a library. Do not use the makefiles
provided, they are not designed for Watcom (apart from SDL):
- zlib - zlib
http://www.zlib.org/ - contains a makefile for OS/2, but is out of date and uses EMX http://www.zlib.org/ - contains a makefile for OS/2, but is out
of date and uses EMX
- libpng - libpng
http://www.libpng.org/ - contains an EMX/gcc makefile http://www.libpng.org/ - contains an EMX/gcc makefile
- SDL for OS/2 - SDL for OS/2
I used ftp://ftp.netlabs.org/pub/sdl/SDL-1.2.7-src-20040908a.zip - take SDL.dll and SDL.lib from the src/ directory. I used ftp://ftp.netlabs.org/pub/sdl/SDL-1.2.7-src-20040908a.zip -
take SDL.dll and SDL.lib from the src/ directory.
Note that to use the compiled program, you also need FSLib.dll (from src/ in the SDL zip) and a version of the Scitech If you do not wish to build the libraries yourself, pre-built versions
Display Drivers or its later incarnation (see www.scitech.com). can be downloaded from the Files section at
http://sourceforge.net/projects/openttd/ - see "os2-useful.zip".
Compiling Compiling
--------- ---------
To compile, open the os/os2/openttd.wpj file in the IDE and build the openttd.exe target. To compile, open the os/os2/openttd.wpj file in the IDE and first build
the strgen.exe target. This will build the .lng file generator, and will
also attempt to build all the language files (plus the table\strings.h
file which is required for openttd.exe to be built). Once strgen.exe and
the language files are built successfully, you can build the openttd.exe
target.
TODO: compilation of language files properly Contact Information
-------------------
If you have any questions regarding OS/2 issues, please contact me
(owen@owenrudge.net) and I'll try to help you out. For general OpenTTD
issues, see the Contacting section of readme.txt.
** THESE DOCS ARE INCOMPLETE FOR THE MOMENT, WILL BE COMPLETED SOON ** - Owen Rudge, 26th December 2004
If you have any questions, please contact me (owen@owenrudge.net) and I'll try to help you out
- Owen Rudge, 18th December 2004

View File

@ -22,13 +22,13 @@ openttd \- An open source clone of the Microprose game "Transport Tycoon Deluxe
.RI [ options ] .RI [ options ]
.br .br
.SH DESCRIPTION .SH DESCRIPTION
Unfortanetely, there is no real manpage for openttd yet. Hopefully someone Unfortunately, there is no real manpage for openttd yet. Hopefully someone
will write one soon. For now you should use will write one soon. For now you should use
.B openttd -h .B openttd -h
for more information, or check our Wiki manual: http://wiki.openttd.org/ for more information, or check our Wiki manual: http://wiki.openttd.org/
.PP .PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and .\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics, .\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
.\" respectively. .\" respectively.
.\" \fBopenttd\fP is a program that... .\" \fBopenttd\fP is a program that...
.SH OPTIONS .SH OPTIONS

View File

@ -1,6 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "ttd.h" #include "ttd.h"
#if defined(UNIX) #if defined(UNIX) || defined(__OS2__)
#include <ctype.h> // required for tolower() #include <ctype.h> // required for tolower()
#endif #endif

4
hal.h
View File

@ -71,6 +71,10 @@ extern const HalMusicDriver _extmidi_music_driver;
extern const HalMusicDriver _bemidi_music_driver; extern const HalMusicDriver _bemidi_music_driver;
#endif #endif
#if defined(__OS2__)
extern const HalMusicDriver _os2_music_driver;
#endif
extern const HalVideoDriver _dedicated_video_driver; extern const HalVideoDriver _dedicated_video_driver;
enum DriverType { enum DriverType {

View File

@ -199,6 +199,8 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
SetDParam(0, STR_OSNAME_MORPHOS); SetDParam(0, STR_OSNAME_MORPHOS);
#elif defined(__AMIGA__) #elif defined(__AMIGA__)
SetDParam(0, STR_OSNAME_AMIGAOS); SetDParam(0, STR_OSNAME_AMIGAOS);
#elif defined(__OS2__)
SetDParam(0, STR_OSNAME_OS2);
#else #else
SetDParam(0, STR_0134_UNIX); SetDParam(0, STR_0134_UNIX);
#endif #endif

View File

@ -311,6 +311,7 @@ STR_0135_OSX :OS X
STR_OSNAME_BEOS :BeOS STR_OSNAME_BEOS :BeOS
STR_OSNAME_MORPHOS :MorphOS STR_OSNAME_MORPHOS :MorphOS
STR_OSNAME_AMIGAOS :AmigaOS STR_OSNAME_AMIGAOS :AmigaOS
STR_OSNAME_OS2 :OS/2
STR_0139_IMPERIAL_MILES :Imperial (miles) STR_0139_IMPERIAL_MILES :Imperial (miles)
STR_013A_METRIC_KILOMETERS :Metric (kilometers) STR_013A_METRIC_KILOMETERS :Metric (kilometers)

View File

@ -88,7 +88,7 @@ typedef struct ifreq IFREQ;
typedef struct ifreq IFREQ; typedef struct ifreq IFREQ;
# define ioctlsocket ioctl # define ioctlsocket ioctl
# define closesocket close # define closesocket close
# define GET_LAST_ERROR() (errno) # define GET_LAST_ERROR() (sock_errno())
// Includes needed for OS/2 systems // Includes needed for OS/2 systems
# include <types.h> # include <types.h>
@ -103,6 +103,7 @@ typedef struct ifreq IFREQ;
# include <sys/time.h> # include <sys/time.h>
# include <netdb.h> # include <netdb.h>
# include <nerrno.h> # include <nerrno.h>
# define INADDR_NONE 0xffffffff
typedef unsigned long in_addr_t; typedef unsigned long in_addr_t;
#endif // OS/2 #endif // OS/2

File diff suppressed because it is too large Load Diff

View File

@ -42,8 +42,8 @@ WRect
WFileName WFileName
17 17
..\..\openttd.tgt ..\..\openttd.tgt
51 47
52 47
11 11
VComponent VComponent
12 12

217
os2.c
View File

@ -6,10 +6,16 @@
#include <direct.h> #include <direct.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdarg.h>
#include <time.h> #include <time.h>
#include <dos.h> #include <dos.h>
#define INCL_DOS
#define INCL_WINDIALOGS
#define INCL_OS2MM
#include <os2.h> #include <os2.h>
#include <os2me.h>
#if defined(WITH_SDL) #if defined(WITH_SDL)
#include <SDL.h> #include <SDL.h>
@ -27,6 +33,7 @@ static FiosItem *FiosAlloc()
_fios_alloc += 256; _fios_alloc += 256;
_fios_items = realloc(_fios_items, _fios_alloc * sizeof(FiosItem)); _fios_items = realloc(_fios_items, _fios_alloc * sizeof(FiosItem));
} }
return &_fios_items[_fios_count++]; return &_fios_items[_fios_count++];
} }
@ -45,6 +52,22 @@ int compare_FiosItems (const void *a, const void *b) {
} }
static DIR *my_opendir(char *path, char *file)
{
char paths[MAX_PATH];
append_path(paths, path, file);
return opendir(paths);
}
static void append_path(char *out, char *path, char *file)
{
if ((path[2] == '\\') && (path[3] == 0))
sprintf(out, "%s%s", path, file);
else
sprintf(out, "%s\\%s", path, file);
}
// Get a list of savegames // Get a list of savegames
FiosItem *FiosGetSavegameList(int *num, int mode) FiosItem *FiosGetSavegameList(int *num, int mode)
{ {
@ -60,32 +83,31 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
strcpy(_fios_save_path, _path.save_dir); strcpy(_fios_save_path, _path.save_dir);
} }
if(_game_mode==GM_EDITOR) if (_game_mode == GM_EDITOR)
_fios_path = _fios_scn_path; _fios_path = _fios_scn_path;
else else
_fios_path = _fios_save_path; _fios_path = _fios_save_path;
// Parent directory, only if not in root already. // Parent directory, only if not of the type C:\.
if (_fios_path[1] != 0) { if (_fios_path[3] != 0) {
fios = FiosAlloc(); fios = FiosAlloc();
fios->type = FIOS_TYPE_PARENT; fios->type = FIOS_TYPE_PARENT;
fios->mtime = 0; strcpy(fios->title, ".. (Parent directory)");
sprintf(fios->title, ".. (Parent directory)");
} }
// Show subdirectories first // Show subdirectories first
dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) { if (dir != NULL) {
while ((dirent = readdir(dir))) { while ((dirent = readdir(dir))) {
sprintf (filename, "%s\\%s", _fios_path, dirent->d_name); append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) { if (!stat(filename, &sb)) {
if (S_ISDIR(sb.st_mode)) { if (S_ISDIR(sb.st_mode)) {
if (dirent->d_name[0] != '.') { if (!(dirent->d_name[0] == '.' && (dirent->d_name[1] == 0 || (dirent->d_name[1] == '.' && dirent->d_name[2] == 0))))
{
fios = FiosAlloc(); fios = FiosAlloc();
fios->mtime = 0;
fios->type = FIOS_TYPE_DIR; fios->type = FIOS_TYPE_DIR;
fios->title[0] = 0; strcpy(fios->name, dirent->d_name);
sprintf(fios->name, "%s\\ (Directory)", dirent->d_name); sprintf(fios->title, "%s\\ (Directory)", dirent->d_name);
} }
} }
} }
@ -110,10 +132,10 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
* .SV1 Transport Tycoon Deluxe (Patch) saved game * .SV1 Transport Tycoon Deluxe (Patch) saved game
* .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game * .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game
*/ */
dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) { if (dir != NULL) {
while ((dirent = readdir(dir))) { while ((dirent = readdir(dir))) {
sprintf (filename, "%s\\%s", _fios_path, dirent->d_name); append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) { if (!stat(filename, &sb)) {
if (!S_ISDIR(sb.st_mode)) { if (!S_ISDIR(sb.st_mode)) {
char *t = strrchr(dirent->d_name, '.'); char *t = strrchr(dirent->d_name, '.');
@ -185,25 +207,35 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
int sort_start; int sort_start;
char filename[MAX_PATH]; char filename[MAX_PATH];
if (_fios_scn_path == NULL) { if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) {
_fios_scn_path = malloc(MAX_PATH); if (_fios_scn_path == NULL)
_fios_scn_path = malloc(MAX_PATH);
strcpy(_fios_scn_path, _path.scenario_dir); strcpy(_fios_scn_path, _path.scenario_dir);
} }
_fios_path = _fios_scn_path; _fios_path = _fios_scn_path;
// Parent directory, only if not of the type C:\.
if (_fios_path[3] != 0 && mode != SLD_NEW_GAME) {
fios = FiosAlloc();
fios->type = FIOS_TYPE_PARENT;
strcpy(fios->title, ".. (Parent directory)");
}
// Show subdirectories first // Show subdirectories first
dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) { if (dir != NULL) {
while ((dirent = readdir(dir))) { while ((dirent = readdir(dir))) {
sprintf (filename, "%s\\%s", _fios_path, dirent->d_name); append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) { if (!stat(filename, &sb)) {
if (S_ISDIR(sb.st_mode)) { if (S_ISDIR(sb.st_mode)) {
if (dirent->d_name[0] != '.') { if (!(dirent->d_name[0] == '.' && (dirent->d_name[1] == 0 || (dirent->d_name[1] == '.' && dirent->d_name[2] == 0))))
{
fios = FiosAlloc(); fios = FiosAlloc();
fios->mtime = 0; fios->mtime = 0;
fios->type = FIOS_TYPE_DIR; fios->type = FIOS_TYPE_DIR;
fios->title[0] = 0; strcpy(fios->name, dirent->d_name);
sprintf(fios->name, "%s\\ (Directory)", dirent->d_name); sprintf(fios->title, "%s\\ (Directory)", dirent->d_name);
} }
} }
} }
@ -219,10 +251,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
* .SV0 Transport Tycoon Deluxe (Patch) scenario * .SV0 Transport Tycoon Deluxe (Patch) scenario
* .SS0 Transport Tycoon Deluxe preset scenario * .SS0 Transport Tycoon Deluxe preset scenario
*/ */
dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) { if (dir != NULL) {
while ((dirent = readdir(dir))) { while ((dirent = readdir(dir))) {
sprintf (filename, "%s\\%s", _fios_path, dirent->d_name); append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) { if (!stat(filename, &sb)) {
if (!S_ISDIR(sb.st_mode)) { if (!S_ISDIR(sb.st_mode)) {
char *t = strrchr(dirent->d_name, '.'); char *t = strrchr(dirent->d_name, '.');
@ -301,16 +333,28 @@ char *FiosBrowseTo(const FiosItem *item)
char *s; char *s;
switch(item->type) { switch(item->type) {
case FIOS_TYPE_DRIVE:
sprintf(path, "%c:\\", item->title[0]);
break;
case FIOS_TYPE_PARENT: case FIOS_TYPE_PARENT:
s = strrchr(path, '\\'); // Skip drive part
if (s != NULL) *s = 0; path += 3;
s = path;
while (*path) {
if (*path== '\\')
s = path;
path++;
}
*s = 0;
break; break;
case FIOS_TYPE_DIR: case FIOS_TYPE_DIR:
s = strchr((char*)item->name, '\\'); // Scan to end
if (s) *s = 0; while (*++path);
while (*path) path++; // Add backslash?
*path++ = '\\'; if (path[-1] != '\\') *path++ = '\\';
strcpy(path, item->name); strcpy(path, item->name);
break; break;
@ -325,7 +369,6 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_SCENARIO: case FIOS_TYPE_SCENARIO:
sprintf(str_buffr, "%s\\%s.scn", path, item->name); sprintf(str_buffr, "%s\\%s.scn", path, item->name);
return str_buffr; return str_buffr;
case FIOS_TYPE_OLD_SCENARIO: case FIOS_TYPE_OLD_SCENARIO:
sprintf(str_buffr, "%s\\%s.%s", path, item->name, _old_extensions[item->old_extension]); sprintf(str_buffr, "%s\\%s.%s", path, item->name, _old_extensions[item->old_extension]);
return str_buffr; return str_buffr;
@ -342,11 +385,11 @@ StringID FiosGetDescText(const char **path)
struct diskfree_t free; struct diskfree_t free;
char drive; char drive;
*path = _fios_path[0] ? _fios_path : "C:\\"; *path = _fios_path;
drive = 'B' - *path[0]; drive = *path[0] - 'A'+1;
_getdiskfree(drive, &free); _getdiskfree(drive, &free);
SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector); SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector);
return STR_4005_BYTES_FREE; return STR_4005_BYTES_FREE;
} }
@ -367,33 +410,33 @@ void FiosDelete(const char *name)
} }
const DriverDesc _video_driver_descs[] = { const DriverDesc _video_driver_descs[] = {
{"null", "Null Video Driver", &_null_video_driver, 0}, { "null", "Null Video Driver", &_null_video_driver, 0},
#if defined(WITH_SDL) #if defined(WITH_SDL)
{ "sdl", "SDL Video Driver", &_sdl_video_driver, 1}, { "sdl", "SDL Video Driver", &_sdl_video_driver, 1},
#endif #endif
{ "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0}, { "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0},
{ NULL, NULL, NULL, 0} { NULL, NULL, NULL, 0}
}; };
const DriverDesc _sound_driver_descs[] = { const DriverDesc _sound_driver_descs[] = {
{"null", "Null Sound Driver", &_null_sound_driver, 0}, { "null", "Null Sound Driver", &_null_sound_driver, 0},
#if defined(WITH_SDL) #if defined(WITH_SDL)
{ "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1}, { "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
#endif #endif
{ NULL, NULL, NULL, 0} { NULL, NULL, NULL, 0}
}; };
const DriverDesc _music_driver_descs[] = { const DriverDesc _music_driver_descs[] = {
{ "null", "Null Music Driver", &_null_music_driver, 0}, { "os2", "OS/2 Music Driver", &_os2_music_driver, 0},
{ NULL, NULL, NULL, 0} { "null", "Null Music Driver", &_null_music_driver, 1},
{ NULL, NULL, NULL, 0}
}; };
/* GetOSVersion returns the minimal required version of OS to be able to use that driver. /* GetOSVersion returns the minimal required version of OS to be able to use that driver.
Not needed for *nix. */ Not needed for OS/2. */
byte GetOSVersion() byte GetOSVersion()
{ {
return 2; // any arbitrary number bigger then 0 return 2; // any arbitrary number bigger then 0
// numbers lower than 2 breaks default music selection on mac
} }
bool FileExists(const char *filename) bool FileExists(const char *filename)
@ -438,15 +481,15 @@ static void ChangeWorkingDirectory(char *exe)
} }
} }
// for some reason these calls don't actually work properly :/
void ShowInfo(const char *str) void ShowInfo(const char *str)
{ {
puts(str); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, str, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_INFORMATION);
} }
void ShowOSErrorBox(const char *buf) void ShowOSErrorBox(const char *buf)
{ {
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 263, MB_OK | MB_APPLMODAL | MB_MOVEABLE | MB_ERROR); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_ERROR);
// TODO: FIX, doesn't always appear
} }
int CDECL main(int argc, char* argv[]) int CDECL main(int argc, char* argv[])
@ -529,3 +572,85 @@ void DeterminePaths()
mkdir(_path.scenario_dir); mkdir(_path.scenario_dir);
} }
// FUNCTION: OS2_SwitchToConsoleMode
//
// Switches OpenTTD to a console app at run-time, instead of a PM app
// Necessary to see stdout, etc
void OS2_SwitchToConsoleMode()
{
PPIB pib;
PTIB tib;
DosGetInfoBlocks(&tib, &pib);
// Change flag from PM to VIO
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()
{
MidiSendCommand("close all");
}
static void OS2MidiSetVolume(byte vol)
{
MidiSendCommand("set song audio volume %d", ((vol/127)*100));
}
static bool OS2MidiIsSongPlaying()
{
char buf[16];
mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
}
static char *OS2MidiStart(char **parm)
{
return 0;
}
static void OS2MidiStop()
{
MidiSendCommand("close all");
}
const HalMusicDriver _os2_music_driver = {
OS2MidiStart,
OS2MidiStop,
OS2MidiPlaySong,
OS2MidiStopSong,
OS2MidiIsSongPlaying,
OS2MidiSetVolume,
};

2
sdl.c
View File

@ -408,7 +408,7 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
} }
// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards) // check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
#if defined(WIN32) #if defined(WIN32) || defined(__OS2__)
if (sym->scancode == 41) key |= WKC_BACKQUOTE; if (sym->scancode == 41) key |= WKC_BACKQUOTE;
#elif defined(__APPLE__) #elif defined(__APPLE__)
if (sym->scancode == 10) key |= WKC_BACKQUOTE; if (sym->scancode == 10) key |= WKC_BACKQUOTE;

View File

@ -15,13 +15,15 @@ WString
oc2en oc2en
1 1
0 0
1 0
4 4
MCommand MCommand
0 0
5 5
MCommand MCommand
0 26
..\os\os2\build_lang.cmd
6 6
MItem MItem
10 10
@ -77,44 +79,68 @@ WString
COBJ COBJ
19 19
WVList WVList
0 2
20 20
MRState
21
WString
3
WCC
22
WString
29
?????No debugging information
0
1
23
MRState
24
WString
3
WCC
25
WString
28
?????Line number information
0
0
26
WVList WVList
0 0
-1 -1
1 1
1 1
0 0
21 27
MItem MItem
8 8
stdafx.c stdafx.c
22 28
WString WString
4 4
COBJ COBJ
23 29
WVList WVList
0 0
24 30
WVList WVList
0 0
17 17
1 1
1 1
0 0
25 31
MItem MItem
8 8
strgen.c strgen.c
26 32
WString WString
4 4
COBJ COBJ
27 33
WVList WVList
0 0
28 34
WVList WVList
0 0
17 17