From a614dd717420b3713f629f8eabe5607c550dedcd Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 26 Nov 2008 13:12:45 +0000 Subject: (svn r14636) -Add: DOS port of OpenTTD, without network support though. --- src/fileio.cpp | 8 ++++++-- src/intro_gui.cpp | 2 ++ src/lang/english.txt | 1 + src/os_timer.cpp | 2 +- src/stdafx.h | 4 ++-- src/video/allegro_v.cpp | 18 ++++++++++++++---- 6 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/fileio.cpp b/src/fileio.cpp index f7b4a5af2..0e2d4d895 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -773,6 +773,10 @@ void ChangeWorkingDirectory(const char *exe) char *s = strrchr(exe, PATHSEPCHAR); if (s != NULL) { *s = '\0'; +#if defined(__DJGPP__) + /* If we want to go to the root, we can't use cd C:, but we must use '/' */ + if (s[-1] == ':') chdir("/"); +#endif if (chdir(exe) != 0) DEBUG(misc, 0, "Directory with the binary does not exist?"); *s = PATHSEPCHAR; } @@ -788,7 +792,7 @@ void ChangeWorkingDirectory(const char *exe) void DetermineBasePaths(const char *exe) { char tmp[MAX_PATH]; -#if defined(__MORPHOS__) || defined(__AMIGA__) || !defined(WITH_PERSONAL_DIR) +#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) || !defined(WITH_PERSONAL_DIR) _searchpaths[SP_PERSONAL_DIR] = NULL; #else const char *homedir = getenv("HOME"); @@ -826,7 +830,7 @@ void DetermineBasePaths(const char *exe) AppendPathSeparator(tmp, MAX_PATH); _searchpaths[SP_BINARY_DIR] = strdup(tmp); -#if defined(__MORPHOS__) || defined(__AMIGA__) +#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) _searchpaths[SP_INSTALLATION_DIR] = NULL; #else snprintf(tmp, MAX_PATH, "%s", GLOBAL_DATA_DIR); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 0cd4f9598..6cd94aa00 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -161,6 +161,8 @@ void AskExitGame() SetDParam(0, STR_OSNAME_OS2); #elif defined(SUNOS) SetDParam(0, STR_OSNAME_SUNOS); +#elif defined(DOS) + SetDParam(0, STR_OSNAME_DOS); #else SetDParam(0, STR_OSNAME_UNIX); #endif diff --git a/src/lang/english.txt b/src/lang/english.txt index d77741b02..370e94b31 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -277,6 +277,7 @@ STR_0131_TOO_MANY_NAMES_DEFINED :{WHITE}Too many STR_0132_CHOSEN_NAME_IN_USE_ALREADY :{WHITE}Chosen name already in use STR_OSNAME_WINDOWS :Windows +STR_OSNAME_DOS :DOS STR_OSNAME_UNIX :Unix STR_OSNAME_OSX :OS X STR_OSNAME_BEOS :BeOS diff --git a/src/os_timer.cpp b/src/os_timer.cpp index 0166a445c..bf0a171de 100644 --- a/src/os_timer.cpp +++ b/src/os_timer.cpp @@ -35,7 +35,7 @@ unsigned __int64 ottd_rdtsc(); #endif /* rdtsc for all other *nix-en (hopefully). Use GCC syntax */ -#if defined(__i386__) || defined(__x86_64__) && !defined(RDTSC_AVAILABLE) +#if (defined(__i386__) || defined(__x86_64__)) && !defined(__DJGPP__) && !defined(RDTSC_AVAILABLE) uint64 ottd_rdtsc() { uint32 high, low; diff --git a/src/stdafx.h b/src/stdafx.h index a0d715ed3..6fdc4fd37 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -353,7 +353,7 @@ void NORETURN CDECL usererror(const char *str, ...); void NORETURN CDECL error(const char *str, ...); #define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__) -#if defined(MORPHOS) || defined(__NDS__) +#if defined(MORPHOS) || defined(__NDS__) || defined(__DJGPP__) /* MorphOS and NDS don't have C++ conformant _stricmp... */ #define _stricmp stricmp #elif defined(OPENBSD) @@ -361,7 +361,7 @@ void NORETURN CDECL error(const char *str, ...); #define _stricmp strcasecmp #endif -#if !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) +#if !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) && !defined(__DJGPP__) /* NDS, MorphOS & OpenBSD don't know wchars, the rest does :( */ #define HAS_WCHAR #endif /* !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) */ diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 913411e6e..36581bcaa 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -179,13 +179,19 @@ static bool CreateMainSurface(int w, int h) if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals"); set_color_depth(bpp); +#if defined(DOS) + /* Force DOS builds to ALWAYS use full screen as + * it can't do windowed. */ + _fullscreen = true; +#endif + GetVideoModes(); GetAvailableVideoMode(&w, &h); if (set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) return false; - _allegro_screen = create_bitmap(screen->w, screen->h); - _screen.width = screen->w; - _screen.height = screen->h; + _allegro_screen = create_bitmap(w, h); + _screen.width = w; + _screen.height = h; _screen.pitch = ((byte*)screen->line[1] - (byte*)screen->line[0]) / (bitmap_color_depth(screen) / 8); poll_mouse(); @@ -399,7 +405,7 @@ void VideoDriver_Allegro::Stop() if (--_allegro_instance_count == 0) allegro_exit(); } -#if defined(UNIX) || defined(__OS2__) || defined(PSP) +#if defined(UNIX) || defined(__OS2__) || defined(PSP) || defined(DOS) # include /* gettimeofday */ static uint32 GetTime() @@ -490,6 +496,9 @@ bool VideoDriver_Allegro::ChangeResolution(int w, int h) bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen) { +#ifdef DOS + return false; +#else _fullscreen = fullscreen; GetVideoModes(); // get the list of available video modes if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) { @@ -498,6 +507,7 @@ bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen) return false; } return true; +#endif } #endif /* WITH_ALLEGRO */ -- cgit v1.2.3-54-g00ecf