From 1f4c1e8821dfbb6bbb3e14e544d0801a0dfc8ac8 Mon Sep 17 00:00:00 2001 From: truelight Date: Mon, 27 Dec 2004 10:40:04 +0000 Subject: [PATCH] (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 --- dedicated.c | 7 + docs/Readme_OS2.txt | 110 +++- docs/openttd.6 | 4 +- fileio.c | 2 +- hal.h | 4 + intro_gui.c | 2 + lang/english.txt | 1 + network_core.h | 3 +- openttd.tgt | 1330 ++++++++++++++++++++++--------------------- os/os2/openttd.wpj | 4 +- os2.c | 217 +++++-- sdl.c | 2 +- strgen/strgen.tgt | 48 +- 13 files changed, 989 insertions(+), 745 deletions(-) diff --git a/dedicated.c b/dedicated.c index ed9df3b58c..223015a145 100644 --- a/dedicated.c +++ b/dedicated.c @@ -20,6 +20,8 @@ # include # include # define STDIN 0 /* file descriptor for standard input */ + + extern void OS2_SwitchToConsoleMode(); #endif #ifdef UNIX @@ -100,6 +102,11 @@ static const char *DedicatedVideoStart(char **parm) { SetConsoleTitle("OpenTTD Dedicated Server"); #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..."); return NULL; } diff --git a/docs/Readme_OS2.txt b/docs/Readme_OS2.txt index 2ef9d0e18e..49e6de9895 100644 --- a/docs/Readme_OS2.txt +++ b/docs/Readme_OS2.txt @@ -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 -can compile and work to an extent. +OpenTTD has been ported to work on OS/2 4.x or later (including +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 -------- -Open Watcom 1.3 was used to build OpenTTD (earlier versions will NOT work). See http://www.openwatcom.org/ to download it. -It may 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. +Open Watcom 1.3 was used to build OpenTTD (earlier versions will +NOT work). See http://www.openwatcom.org/ to download it. It may +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 -should be no reason of course why the OS/2 version cannot be used. +Due to complexities in my set-up, I actually used the Win32 version +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 ------------------ -The following libraries are required. To build zlib and libpng, I simply added the required files (watch out for sample -programs, etc) to an IDE project file and built a library: +The following libraries are required. To build zlib and libpng, I +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 - 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 http://www.libpng.org/ - contains an EMX/gcc makefile - 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 -Display Drivers or its later incarnation (see www.scitech.com). +If you do not wish to build the libraries yourself, pre-built versions +can be downloaded from the Files section at +http://sourceforge.net/projects/openttd/ - see "os2-useful.zip". 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 ** - -If you have any questions, please contact me (owen@owenrudge.net) and I'll try to help you out - -- Owen Rudge, 18th December 2004 - +- Owen Rudge, 26th December 2004 \ No newline at end of file diff --git a/docs/openttd.6 b/docs/openttd.6 index 39736436d4..ca0d329f7d 100644 --- a/docs/openttd.6 +++ b/docs/openttd.6 @@ -22,13 +22,13 @@ openttd \- An open source clone of the Microprose game "Transport Tycoon Deluxe .RI [ options ] .br .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 .B openttd -h for more information, or check our Wiki manual: http://wiki.openttd.org/ .PP .\" TeX users may be more comfortable with the \fB\fP and -.\" \fI\fP escape sequences to invode bold face and italics, +.\" \fI\fP escape sequences to invoke bold face and italics, .\" respectively. .\" \fBopenttd\fP is a program that... .SH OPTIONS diff --git a/fileio.c b/fileio.c index 5645d338fe..27a22b193a 100644 --- a/fileio.c +++ b/fileio.c @@ -1,6 +1,6 @@ #include "stdafx.h" #include "ttd.h" -#if defined(UNIX) +#if defined(UNIX) || defined(__OS2__) #include // required for tolower() #endif diff --git a/hal.h b/hal.h index faf2892b4c..9941c47491 100644 --- a/hal.h +++ b/hal.h @@ -71,6 +71,10 @@ extern const HalMusicDriver _extmidi_music_driver; extern const HalMusicDriver _bemidi_music_driver; #endif +#if defined(__OS2__) +extern const HalMusicDriver _os2_music_driver; +#endif + extern const HalVideoDriver _dedicated_video_driver; enum DriverType { diff --git a/intro_gui.c b/intro_gui.c index baa64d7850..cb3b8a055e 100644 --- a/intro_gui.c +++ b/intro_gui.c @@ -199,6 +199,8 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) { SetDParam(0, STR_OSNAME_MORPHOS); #elif defined(__AMIGA__) SetDParam(0, STR_OSNAME_AMIGAOS); +#elif defined(__OS2__) + SetDParam(0, STR_OSNAME_OS2); #else SetDParam(0, STR_0134_UNIX); #endif diff --git a/lang/english.txt b/lang/english.txt index 44e9be3d78..6358168704 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -311,6 +311,7 @@ STR_0135_OSX :OS X STR_OSNAME_BEOS :BeOS STR_OSNAME_MORPHOS :MorphOS STR_OSNAME_AMIGAOS :AmigaOS +STR_OSNAME_OS2 :OS/2 STR_0139_IMPERIAL_MILES :Imperial (miles) STR_013A_METRIC_KILOMETERS :Metric (kilometers) diff --git a/network_core.h b/network_core.h index bf29116ec0..f341531de3 100644 --- a/network_core.h +++ b/network_core.h @@ -88,7 +88,7 @@ typedef struct ifreq IFREQ; typedef struct ifreq IFREQ; # define ioctlsocket ioctl # define closesocket close -# define GET_LAST_ERROR() (errno) +# define GET_LAST_ERROR() (sock_errno()) // Includes needed for OS/2 systems # include @@ -103,6 +103,7 @@ typedef struct ifreq IFREQ; # include # include # include +# define INADDR_NONE 0xffffffff typedef unsigned long in_addr_t; #endif // OS/2 diff --git a/openttd.tgt b/openttd.tgt index 775586d3a6..4661b09963 100644 --- a/openttd.tgt +++ b/openttd.tgt @@ -130,8 +130,8 @@ WString 0 33 WString -24 -png.lib zlib.lib sdl.lib +34 +mmpm2.lib png.lib zlib.lib sdl.lib 0 34 MVState @@ -205,7 +205,7 @@ WString COBJ 54 WVList -14 +15 55 MVState 56 @@ -343,17 +343,17 @@ WString ENABLE_NETWORK=1 WITH_ZLIB=1 WITH_PNG=1 WITH_SDL=1 0 89 -MRState +MCState 90 WString 3 WCC 91 WString -20 -?????Pack structures -0 +31 +?????Force enums to be type int 0 +1 92 MRState 93 @@ -362,10 +362,10 @@ WString WCC 94 WString -21 -?????4 byte alignment +20 +?????Pack structures +0 0 -1 95 MRState 96 @@ -374,8 +374,8 @@ WString WCC 97 WString -29 -?????No debugging information +21 +?????4 byte alignment 0 1 98 @@ -386,1703 +386,1715 @@ WString WCC 100 WString +29 +?????No debugging information +0 +1 +101 +MRState +102 +WString +3 +WCC +103 +WString 28 ?????Line number information 0 0 -101 +104 WVList 0 -1 1 1 0 -102 +105 MItem 4 ai.c -103 -WString -4 -COBJ -104 -WVList -0 -105 -WVList -0 -52 -1 -1 -0 106 -MItem -10 -ai_build.c -107 WString 4 COBJ +107 +WVList +0 108 WVList 0 -109 -WVList -0 52 1 1 0 -110 +109 MItem -8 -ai_new.c -111 +10 +ai_build.c +110 WString 4 COBJ +111 +WVList +0 112 WVList 0 -113 -WVList -0 52 1 1 0 -114 +113 MItem -15 -ai_pathfinder.c -115 +8 +ai_new.c +114 WString 4 COBJ +115 +WVList +0 116 WVList 0 -117 -WVList -0 52 1 1 0 -118 +117 MItem -11 -ai_shared.c -119 +15 +ai_pathfinder.c +118 WString 4 COBJ +119 +WVList +0 120 WVList 0 -121 -WVList -0 52 1 1 0 -122 +121 MItem -14 -aircraft_cmd.c -123 +11 +ai_shared.c +122 WString 4 COBJ +123 +WVList +0 124 WVList 0 -125 -WVList -0 52 1 1 0 -126 +125 MItem 14 -aircraft_gui.c -127 +aircraft_cmd.c +126 WString 4 COBJ +127 +WVList +0 128 WVList 0 -129 -WVList -0 52 1 1 0 -130 +129 MItem -9 -airport.c -131 +14 +aircraft_gui.c +130 WString 4 COBJ +131 +WVList +0 132 WVList 0 -133 -WVList -0 52 1 1 0 -134 +133 MItem -13 -airport_gui.c -135 +9 +airport.c +134 WString 4 COBJ +135 +WVList +0 136 WVList 0 -137 -WVList -0 52 1 1 0 -138 +137 MItem -8 -aystar.c -139 +13 +airport_gui.c +138 WString 4 COBJ +139 +WVList +0 140 WVList 0 -141 -WVList -0 52 1 1 0 -142 +141 MItem -12 -bridge_gui.c -143 +8 +aystar.c +142 WString 4 COBJ +143 +WVList +0 144 WVList 0 -145 -WVList -0 52 1 1 0 -146 +145 MItem -16 -callback_table.c -147 +12 +bridge_gui.c +146 WString 4 COBJ +147 +WVList +0 148 WVList 0 -149 -WVList -0 52 1 1 0 -150 +149 MItem -11 -clear_cmd.c -151 +16 +callback_table.c +150 WString 4 COBJ +151 +WVList +0 152 WVList 0 -153 -WVList -0 52 1 1 0 -154 +153 MItem -9 -command.c -155 +11 +clear_cmd.c +154 WString 4 COBJ +155 +WVList +0 156 WVList 0 -157 -WVList -0 52 1 1 0 -158 +157 MItem 9 -console.c -159 +command.c +158 WString 4 COBJ +159 +WVList +0 160 WVList 0 -161 -WVList -0 52 1 1 0 -162 +161 MItem -14 -console_cmds.c -163 +9 +console.c +162 WString 4 COBJ +163 +WVList +0 164 WVList 0 -165 -WVList -0 52 1 1 0 -166 +165 MItem -11 -dedicated.c -167 +14 +console_cmds.c +166 WString 4 COBJ +167 +WVList +0 168 WVList 0 -169 -WVList -0 52 1 1 0 -170 +169 MItem -14 -disaster_cmd.c -171 +11 +dedicated.c +170 WString 4 COBJ +171 +WVList +0 172 WVList 0 -173 -WVList -0 52 1 1 0 -174 +173 MItem -10 -dock_gui.c -175 +14 +disaster_cmd.c +174 WString 4 COBJ +175 +WVList +0 176 WVList 0 -177 -WVList -0 52 1 1 0 -178 +177 MItem -12 -dummy_land.c -179 +10 +dock_gui.c +178 WString 4 COBJ +179 +WVList +0 180 WVList 0 -181 -WVList -0 52 1 1 0 -182 +181 MItem -9 -economy.c -183 +12 +dummy_land.c +182 WString 4 COBJ +183 +WVList +0 184 WVList 0 -185 -WVList -0 52 1 1 0 -186 +185 MItem -8 -engine.c -187 +9 +economy.c +186 WString 4 COBJ +187 +WVList +0 188 WVList 0 -189 -WVList -0 52 1 1 0 -190 +189 MItem -12 -engine_gui.c -191 +8 +engine.c +190 WString 4 COBJ +191 +WVList +0 192 WVList 0 -193 -WVList -0 52 1 1 0 -194 +193 MItem -8 -fileio.c -195 +12 +engine_gui.c +194 WString 4 COBJ +195 +WVList +0 196 WVList 0 -197 -WVList -0 52 1 1 0 -198 +197 MItem -5 -gfx.c -199 +8 +fileio.c +198 WString 4 COBJ +199 +WVList +0 200 WVList 0 -201 -WVList -0 52 1 1 0 -202 +201 MItem -11 -graph_gui.c -203 +5 +gfx.c +202 WString 4 COBJ +203 +WVList +0 204 WVList 0 -205 -WVList -0 52 1 1 0 -206 +205 MItem -14 -industry_cmd.c -207 +11 +graph_gui.c +206 WString 4 COBJ +207 +WVList +0 208 WVList 0 -209 -WVList -0 52 1 1 0 -210 +209 MItem 14 -industry_gui.c -211 +industry_cmd.c +210 WString 4 COBJ +211 +WVList +0 212 WVList 0 -213 -WVList -0 52 1 1 0 -214 +213 MItem -11 -intro_gui.c -215 +14 +industry_gui.c +214 WString 4 COBJ +215 +WVList +0 216 WVList 0 -217 -WVList -0 52 1 1 0 -218 +217 MItem 11 -landscape.c -219 +intro_gui.c +218 WString 4 COBJ +219 +WVList +0 220 WVList 0 -221 -WVList -0 52 1 1 0 -222 +221 MItem -10 -main_gui.c -223 +11 +landscape.c +222 WString 4 COBJ +223 +WVList +0 224 WVList 0 -225 -WVList -0 52 1 1 0 -226 +225 MItem -5 -map.c -227 +10 +main_gui.c +226 WString 4 COBJ +227 +WVList +0 228 WVList 0 -229 -WVList -0 52 1 1 0 -230 +229 MItem 5 -md5.c -231 +map.c +230 WString 4 COBJ +231 +WVList +0 232 WVList 0 -233 -WVList -0 52 1 1 0 -234 +233 MItem -9 -minilzo.c -235 +5 +md5.c +234 WString 4 COBJ +235 +WVList +0 236 WVList 0 -237 -WVList -0 52 1 1 0 -238 +237 MItem -6 -misc.c -239 +9 +minilzo.c +238 WString 4 COBJ +239 +WVList +0 240 WVList 0 -241 -WVList -0 52 1 1 0 -242 +241 MItem -10 -misc_cmd.c -243 +6 +misc.c +242 WString 4 COBJ +243 +WVList +0 244 WVList 0 -245 -WVList -0 52 1 1 0 -246 +245 MItem 10 -misc_gui.c -247 +misc_cmd.c +246 WString 4 COBJ +247 +WVList +0 248 WVList 0 -249 -WVList -0 52 1 1 0 -250 +249 MItem -11 -music_gui.c -251 +10 +misc_gui.c +250 WString 4 COBJ +251 +WVList +0 252 WVList 0 -253 -WVList -0 52 1 1 0 -254 +253 MItem -9 -namegen.c -255 +11 +music_gui.c +254 WString 4 COBJ +255 +WVList +0 256 WVList 0 -257 -WVList -0 52 1 1 0 -258 +257 MItem 9 -network.c -259 +namegen.c +258 WString 4 COBJ +259 +WVList +0 260 WVList 0 -261 -WVList -0 52 1 1 0 -262 +261 MItem -16 -network_client.c -263 +9 +network.c +262 WString 4 COBJ +263 +WVList +0 264 WVList 0 -265 -WVList -0 52 1 1 0 -266 +265 MItem -14 -network_data.c -267 +16 +network_client.c +266 WString 4 COBJ +267 +WVList +0 268 WVList 0 -269 -WVList -0 52 1 1 0 -270 +269 MItem -18 -network_gamelist.c -271 +14 +network_data.c +270 WString 4 COBJ +271 +WVList +0 272 WVList 0 -273 -WVList -0 52 1 1 0 -274 +273 MItem -13 -network_gui.c -275 +18 +network_gamelist.c +274 WString 4 COBJ +275 +WVList +0 276 WVList 0 -277 -WVList -0 52 1 1 0 -278 +277 MItem -16 -network_server.c -279 +13 +network_gui.c +278 WString 4 COBJ +279 +WVList +0 280 WVList 0 -281 -WVList -0 52 1 1 0 -282 +281 MItem -13 -network_udp.c -283 +16 +network_server.c +282 WString 4 COBJ +283 +WVList +0 284 WVList 0 -285 -WVList -0 52 1 1 0 -286 +285 MItem -8 -newgrf.c -287 +13 +network_udp.c +286 WString 4 COBJ +287 +WVList +0 288 WVList 0 -289 -WVList -0 52 1 1 0 -290 +289 MItem -10 -news_gui.c -291 +8 +newgrf.c +290 WString 4 COBJ +291 +WVList +0 292 WVList 0 -293 -WVList -0 52 1 1 0 -294 +293 MItem -11 -oldloader.c -295 +10 +news_gui.c +294 WString 4 COBJ +295 +WVList +0 296 WVList 0 -297 -WVList -0 52 1 1 0 -298 +297 MItem 11 -order_cmd.c -299 +oldloader.c +298 WString 4 COBJ +299 +WVList +0 300 WVList 0 -301 -WVList -0 52 1 1 0 -302 +301 MItem 11 -order_gui.c -303 +order_cmd.c +302 WString 4 COBJ +303 +WVList +0 304 WVList 0 -305 -WVList -0 52 1 1 0 -306 +305 MItem -5 -os2.c -307 +11 +order_gui.c +306 WString 4 COBJ +307 +WVList +0 308 WVList 0 -309 -WVList -0 52 1 1 0 -310 +309 MItem -10 -pathfind.c -311 +5 +os2.c +310 WString 4 COBJ +311 +WVList +0 312 WVList 0 -313 -WVList -0 52 1 1 0 -314 +313 MItem -12 -player_gui.c -315 +10 +pathfind.c +314 WString 4 COBJ +315 +WVList +0 316 WVList 0 -317 -WVList -0 52 1 1 0 -318 +317 MItem -9 -players.c -319 +12 +player_gui.c +318 WString 4 COBJ +319 +WVList +0 320 WVList 0 -321 -WVList -0 52 1 1 0 -322 +321 MItem -7 -queue.c -323 +9 +players.c +322 WString 4 COBJ +323 +WVList +0 324 WVList 0 -325 -WVList -0 52 1 1 0 -326 +325 MItem -10 -rail_cmd.c -327 +7 +queue.c +326 WString 4 COBJ +327 +WVList +0 328 WVList 0 -329 -WVList -0 52 1 1 0 -330 +329 MItem 10 -rail_gui.c -331 +rail_cmd.c +330 WString 4 COBJ +331 +WVList +0 332 WVList 0 -333 -WVList -0 52 1 1 0 -334 +333 MItem 10 -road_cmd.c -335 +rail_gui.c +334 WString 4 COBJ +335 +WVList +0 336 WVList 0 -337 -WVList -0 52 1 1 0 -338 +337 MItem 10 -road_gui.c -339 +road_cmd.c +338 WString 4 COBJ +339 +WVList +0 340 WVList 0 -341 -WVList -0 52 1 1 0 -342 +341 MItem -13 -roadveh_cmd.c -343 +10 +road_gui.c +342 WString 4 COBJ +343 +WVList +0 344 WVList 0 -345 -WVList -0 52 1 1 0 -346 +345 MItem 13 -roadveh_gui.c -347 +roadveh_cmd.c +346 WString 4 COBJ +347 +WVList +0 348 WVList 0 -349 -WVList -0 52 1 1 0 -350 +349 MItem -10 -saveload.c -351 +13 +roadveh_gui.c +350 WString 4 COBJ +351 +WVList +0 352 WVList 0 -353 -WVList -0 52 1 1 0 -354 +353 MItem -12 -screenshot.c -355 +10 +saveload.c +354 WString 4 COBJ +355 +WVList +0 356 WVList 0 -357 -WVList -0 52 1 1 0 -358 +357 MItem -5 -sdl.c -359 +12 +screenshot.c +358 WString 4 COBJ +359 +WVList +0 360 WVList 0 -361 -WVList -0 52 1 1 0 -362 +361 MItem -10 -settings.c -363 +5 +sdl.c +362 WString 4 COBJ +363 +WVList +0 364 WVList 0 -365 -WVList -0 52 1 1 0 -366 +365 MItem -14 -settings_gui.c -367 +10 +settings.c +366 WString 4 COBJ +367 +WVList +0 368 WVList 0 -369 -WVList -0 52 1 1 0 -370 +369 MItem -10 -ship_cmd.c -371 +14 +settings_gui.c +370 WString 4 COBJ +371 +WVList +0 372 WVList 0 -373 -WVList -0 52 1 1 0 -374 +373 MItem 10 -ship_gui.c -375 +ship_cmd.c +374 WString 4 COBJ +375 +WVList +0 376 WVList 0 -377 -WVList -0 52 1 1 0 -378 +377 MItem -14 -smallmap_gui.c -379 +10 +ship_gui.c +378 WString 4 COBJ +379 +WVList +0 380 WVList 0 -381 -WVList -0 52 1 1 0 -382 +381 MItem -7 -sound.c -383 +14 +smallmap_gui.c +382 WString 4 COBJ +383 +WVList +0 384 WVList 0 -385 -WVList -0 52 1 1 0 -386 +385 MItem -8 -sprite.c -387 +7 +sound.c +386 WString 4 COBJ +387 +WVList +0 388 WVList 0 -389 -WVList -0 52 1 1 0 -390 +389 MItem -13 -spritecache.c -391 +8 +sprite.c +390 WString 4 COBJ +391 +WVList +0 392 WVList 0 -393 -WVList -0 52 1 1 0 -394 +393 MItem 13 -station_cmd.c -395 +spritecache.c +394 WString 4 COBJ +395 +WVList +0 396 WVList 0 -397 -WVList -0 52 1 1 0 -398 +397 MItem 13 -station_gui.c -399 +station_cmd.c +398 WString 4 COBJ +399 +WVList +0 400 WVList 0 -401 -WVList -0 52 1 1 0 -402 +401 MItem -8 -StdAfx.c -403 +13 +station_gui.c +402 WString 4 COBJ +403 +WVList +0 404 WVList 0 -405 -WVList -0 52 1 1 0 -406 +405 MItem -9 -strings.c -407 +8 +StdAfx.c +406 WString 4 COBJ +407 +WVList +0 408 WVList 0 -409 -WVList -0 52 1 1 0 -410 +409 MItem -13 -subsidy_gui.c -411 +9 +strings.c +410 WString 4 COBJ +411 +WVList +0 412 WVList 0 -413 -WVList -0 52 1 1 0 -414 +413 MItem -15 -terraform_gui.c -415 +13 +subsidy_gui.c +414 WString 4 COBJ +415 +WVList +0 416 WVList 0 -417 -WVList -0 52 1 1 0 -418 +417 MItem -9 -texteff.c -419 +15 +terraform_gui.c +418 WString 4 COBJ +419 +WVList +0 420 WVList 0 -421 -WVList -0 52 1 1 0 -422 +421 MItem -10 -town_cmd.c -423 +9 +texteff.c +422 WString 4 COBJ +423 +WVList +0 424 WVList 0 -425 -WVList -0 52 1 1 0 -426 +425 MItem 10 -town_gui.c -427 +town_cmd.c +426 WString 4 COBJ +427 +WVList +0 428 WVList 0 -429 -WVList -0 52 1 1 0 -430 +429 MItem -11 -train_cmd.c -431 +10 +town_gui.c +430 WString 4 COBJ +431 +WVList +0 432 WVList 0 -433 -WVList -0 52 1 1 0 -434 +433 MItem 11 -train_gui.c -435 +train_cmd.c +434 WString 4 COBJ +435 +WVList +0 436 WVList 0 -437 -WVList -0 52 1 1 0 -438 +437 MItem -10 -tree_cmd.c -439 +11 +train_gui.c +438 WString 4 COBJ +439 +WVList +0 440 WVList 0 -441 -WVList -0 52 1 1 0 -442 +441 MItem -5 -ttd.c -443 +10 +tree_cmd.c +442 WString 4 COBJ +443 +WVList +0 444 WVList 0 -445 -WVList -0 52 1 1 0 -446 +445 MItem -18 -tunnelbridge_cmd.c -447 +5 +ttd.c +446 WString 4 COBJ +447 +WVList +0 448 WVList 0 -449 -WVList -0 52 1 1 0 -450 +449 MItem -15 -unmovable_cmd.c -451 +18 +tunnelbridge_cmd.c +450 WString 4 COBJ +451 +WVList +0 452 WVList 0 -453 -WVList -0 52 1 1 0 -454 +453 MItem -9 -vehicle.c -455 +15 +unmovable_cmd.c +454 WString 4 COBJ +455 +WVList +0 456 WVList 0 -457 -WVList -0 52 1 1 0 -458 +457 MItem -13 -vehicle_gui.c -459 +9 +vehicle.c +458 WString 4 COBJ +459 +WVList +0 460 WVList 0 -461 -WVList -0 52 1 1 0 -462 +461 MItem -10 -viewport.c -463 +13 +vehicle_gui.c +462 WString 4 COBJ +463 +WVList +0 464 WVList 0 -465 -WVList -0 52 1 1 0 -466 +465 MItem -11 -water_cmd.c -467 +10 +viewport.c +466 WString 4 COBJ +467 +WVList +0 468 WVList 0 -469 -WVList -0 52 1 1 0 -470 +469 MItem -8 -widget.c -471 +11 +water_cmd.c +470 WString 4 COBJ +471 +WVList +0 472 WVList 0 -473 -WVList -0 52 1 1 0 -474 +473 MItem 8 -window.c -475 +widget.c +474 WString 4 COBJ -476 +475 WVList 0 -477 +476 +WVList +0 +52 +1 +1 +0 +477 +MItem +8 +window.c +478 +WString +4 +COBJ +479 +WVList +0 +480 WVList 0 52 diff --git a/os/os2/openttd.wpj b/os/os2/openttd.wpj index f363a28d80..6c36230ade 100644 --- a/os/os2/openttd.wpj +++ b/os/os2/openttd.wpj @@ -42,8 +42,8 @@ WRect WFileName 17 ..\..\openttd.tgt -51 -52 +47 +47 11 VComponent 12 diff --git a/os2.c b/os2.c index ca24170e0d..c43ba71ade 100644 --- a/os2.c +++ b/os2.c @@ -6,10 +6,16 @@ #include #include #include +#include #include #include +#define INCL_DOS +#define INCL_WINDIALOGS +#define INCL_OS2MM + #include +#include #if defined(WITH_SDL) #include @@ -27,6 +33,7 @@ static FiosItem *FiosAlloc() _fios_alloc += 256; _fios_items = realloc(_fios_items, _fios_alloc * sizeof(FiosItem)); } + 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 FiosItem *FiosGetSavegameList(int *num, int mode) { @@ -60,32 +83,31 @@ FiosItem *FiosGetSavegameList(int *num, int mode) strcpy(_fios_save_path, _path.save_dir); } - if(_game_mode==GM_EDITOR) + if (_game_mode == GM_EDITOR) _fios_path = _fios_scn_path; else _fios_path = _fios_save_path; - // Parent directory, only if not in root already. - if (_fios_path[1] != 0) { + // Parent directory, only if not of the type C:\. + if (_fios_path[3] != 0) { fios = FiosAlloc(); fios->type = FIOS_TYPE_PARENT; - fios->mtime = 0; - sprintf(fios->title, ".. (Parent directory)"); + strcpy(fios->title, ".. (Parent directory)"); } // Show subdirectories first - dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); + dir = my_opendir(_fios_path, "*.*"); if (dir != NULL) { 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 (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->mtime = 0; fios->type = FIOS_TYPE_DIR; - fios->title[0] = 0; - sprintf(fios->name, "%s\\ (Directory)", dirent->d_name); + strcpy(fios->name, 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 * .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) { 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 (!S_ISDIR(sb.st_mode)) { char *t = strrchr(dirent->d_name, '.'); @@ -185,25 +207,35 @@ FiosItem *FiosGetScenarioList(int *num, int mode) int sort_start; char filename[MAX_PATH]; - if (_fios_scn_path == NULL) { - _fios_scn_path = malloc(MAX_PATH); + if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { + if (_fios_scn_path == NULL) + _fios_scn_path = malloc(MAX_PATH); strcpy(_fios_scn_path, _path.scenario_dir); } + _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 - dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); + dir = my_opendir(_fios_path, "*.*"); if (dir != NULL) { 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 (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->mtime = 0; fios->type = FIOS_TYPE_DIR; - fios->title[0] = 0; - sprintf(fios->name, "%s\\ (Directory)", dirent->d_name); + strcpy(fios->name, 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 * .SS0 Transport Tycoon Deluxe preset scenario */ - dir = opendir(_fios_path[0] ? _fios_path : "C:\\"); + dir = my_opendir(_fios_path, "*.*"); if (dir != NULL) { 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 (!S_ISDIR(sb.st_mode)) { char *t = strrchr(dirent->d_name, '.'); @@ -301,16 +333,28 @@ char *FiosBrowseTo(const FiosItem *item) char *s; switch(item->type) { + case FIOS_TYPE_DRIVE: + sprintf(path, "%c:\\", item->title[0]); + break; + case FIOS_TYPE_PARENT: - s = strrchr(path, '\\'); - if (s != NULL) *s = 0; + // Skip drive part + path += 3; + s = path; + while (*path) { + if (*path== '\\') + s = path; + path++; + } + *s = 0; break; case FIOS_TYPE_DIR: - s = strchr((char*)item->name, '\\'); - if (s) *s = 0; - while (*path) path++; - *path++ = '\\'; + // Scan to end + while (*++path); + // Add backslash? + if (path[-1] != '\\') *path++ = '\\'; + strcpy(path, item->name); break; @@ -325,7 +369,6 @@ char *FiosBrowseTo(const FiosItem *item) case FIOS_TYPE_SCENARIO: sprintf(str_buffr, "%s\\%s.scn", path, item->name); return str_buffr; - case FIOS_TYPE_OLD_SCENARIO: sprintf(str_buffr, "%s\\%s.%s", path, item->name, _old_extensions[item->old_extension]); return str_buffr; @@ -342,11 +385,11 @@ StringID FiosGetDescText(const char **path) struct diskfree_t free; char drive; - *path = _fios_path[0] ? _fios_path : "C:\\"; - drive = 'B' - *path[0]; + *path = _fios_path; + drive = *path[0] - 'A'+1; _getdiskfree(drive, &free); - + SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector); return STR_4005_BYTES_FREE; } @@ -367,33 +410,33 @@ void FiosDelete(const char *name) } 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) - { "sdl", "SDL Video Driver", &_sdl_video_driver, 1}, + { "sdl", "SDL Video Driver", &_sdl_video_driver, 1}, #endif - { "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0}, - { NULL, NULL, NULL, 0} + { "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0}, + { NULL, NULL, NULL, 0} }; 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) - { "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1}, + { "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1}, #endif - { NULL, NULL, NULL, 0} + { NULL, NULL, NULL, 0} }; const DriverDesc _music_driver_descs[] = { - { "null", "Null Music Driver", &_null_music_driver, 0}, - { NULL, NULL, NULL, 0} + { "os2", "OS/2 Music Driver", &_os2_music_driver, 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. - Not needed for *nix. */ + Not needed for OS/2. */ byte GetOSVersion() { return 2; // any arbitrary number bigger then 0 - // numbers lower than 2 breaks default music selection on mac } 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) { - puts(str); + WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, str, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_INFORMATION); } void ShowOSErrorBox(const char *buf) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 263, MB_OK | MB_APPLMODAL | MB_MOVEABLE | MB_ERROR); -// TODO: FIX, doesn't always appear + WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_ERROR); } int CDECL main(int argc, char* argv[]) @@ -529,3 +572,85 @@ void DeterminePaths() 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, +}; + + diff --git a/sdl.c b/sdl.c index 1fabe26661..c9275f37a6 100644 --- a/sdl.c +++ b/sdl.c @@ -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) -#if defined(WIN32) +#if defined(WIN32) || defined(__OS2__) if (sym->scancode == 41) key |= WKC_BACKQUOTE; #elif defined(__APPLE__) if (sym->scancode == 10) key |= WKC_BACKQUOTE; diff --git a/strgen/strgen.tgt b/strgen/strgen.tgt index 1ef11fe0fb..8eaf49dfb0 100644 --- a/strgen/strgen.tgt +++ b/strgen/strgen.tgt @@ -15,13 +15,15 @@ WString oc2en 1 0 -1 +0 4 MCommand 0 5 MCommand -0 +26 +..\os\os2\build_lang.cmd + 6 MItem 10 @@ -77,44 +79,68 @@ WString COBJ 19 WVList -0 +2 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 0 -1 1 1 0 -21 +27 MItem 8 stdafx.c -22 +28 WString 4 COBJ -23 +29 WVList 0 -24 +30 WVList 0 17 1 1 0 -25 +31 MItem 8 strgen.c -26 +32 WString 4 COBJ -27 +33 WVList 0 -28 +34 WVList 0 17