(svn r17336) -Codechange: move some os specific files into src/os/

This commit is contained in:
rubidium
2009-08-31 22:38:37 +00:00
parent 5cc6d1f894
commit bc8e66c202
25 changed files with 64 additions and 64 deletions

243
src/os/os2/os2.cpp Normal file
View File

@@ -0,0 +1,243 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2.cpp OS2 related OS support. */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../variables.h"
#include "../../gui.h"
#include "../../fileio_func.h"
#include "../../fios.h"
#include "../../functions.h"
#include "../../core/random_func.hpp"
#include "../../string_func.h"
#include "../../textbuf_gui.h"
#include "table/strings.h"
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
#ifndef __INNOTEK_LIBC__
#include <dos.h>
#endif
#define INCL_WIN
#define INCL_WINCLIPBOARD
#include <os2.h>
#ifndef __INNOTEK_LIBC__
#include <i86.h>
#endif
bool FiosIsRoot(const char *file)
{
return file[3] == '\0';
}
void FiosGetDrives()
{
uint disk, disk2, save, total;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&save); // save original drive
#else
save = _getdrive(); // save original drive
char wd[MAX_PATH];
getcwd(wd, MAX_PATH);
total = 'z';
#endif
/* get an available drive letter */
#ifndef __INNOTEK_LIBC__
for (disk = 1;; disk++) {
_dos_setdrive(disk, &total);
#else
for (disk = 'A';; disk++) {
_chdrive(disk);
#endif
if (disk >= total) break;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&disk2);
#else
disk2 = _getdrive();
#endif
if (disk == disk2) {
FiosItem *fios = _fios_items.Append();
fios->type = FIOS_TYPE_DRIVE;
fios->mtime = 0;
#ifndef __INNOTEK_LIBC__
snprintf(fios->name, lengthof(fios->name), "%c:", 'A' + disk - 1);
#else
snprintf(fios->name, lengthof(fios->name), "%c:", disk);
#endif
strecpy(fios->title, fios->name, lastof(fios->title));
}
}
/* Restore the original drive */
#ifndef __INNOTEK_LIBC__
_dos_setdrive(save, &total);
#else
chdir(wd);
#endif
}
bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
{
#ifndef __INNOTEK_LIBC__
struct diskfree_t free;
char drive = path[0] - 'A' + 1;
if (tot != NULL && _getdiskfree(drive, &free) == 0) {
*tot = free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector;
return true;
}
return false;
#else
uint64 free = 0;
#ifdef HAS_STATVFS
{
struct statvfs s;
if (statvfs(path, &s) != 0) return false;
free = (uint64)s.f_frsize * s.f_bavail;
}
#endif
if (tot != NULL) *tot = free;
return true;
#endif
}
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
{
char filename[MAX_PATH];
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
return stat(filename, sb) == 0;
}
bool FiosIsHiddenFile(const struct dirent *ent)
{
return ent->d_name[0] == '.';
}
void ShowInfo(const char *str)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)str, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
void ShowOSErrorBox(const char *buf, bool system)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)buf, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
int CDECL main(int argc, char *argv[])
{
SetRandomSeed(time(NULL));
return ttd_main(argc, argv);
}
/**
* 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
* is zero, we don't care about the screenlength but only about the physical length of the string
* @param tb Textbuf type to be changed
* @return Return true on successful change of Textbuf, or false otherwise
*/
bool InsertTextBufferClipboard(Textbuf *tb)
{
/* XXX -- Currently no clipboard support implemented with GCC */
#ifndef __INNOTEK_LIBC__
HAB hab = 0;
if (WinOpenClipbrd(hab))
{
const char *text = (const char*)WinQueryClipbrdData(hab, CF_TEXT);
if (text != NULL)
{
uint length = 0;
uint width = 0;
const char *i;
for (i = text; IsValidAsciiChar(*i); i++)
{
uint w;
if (tb->size + length + 1 > tb->maxsize) break;
w = GetCharacterWidth(FS_NORMAL, (byte)*i);
if (tb->maxwidth != 0 && width + tb->width + w > tb->maxwidth) break;
width += w;
length++;
}
memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->size - tb->caretpos);
memcpy(tb->buf + tb->caretpos, text, length);
tb->width += width;
tb->caretxoffs += width;
tb->size += length;
tb->caretpos += length;
WinCloseClipbrd(hab);
return true;
}
WinCloseClipbrd(hab);
}
#endif
return false;
}
void CSleep(int milliseconds)
{
#ifndef __INNOTEK_LIBC__
delay(milliseconds);
#else
usleep(milliseconds * 1000);
#endif
}
const char *FS2OTTD(const char *name) {return name;}
const char *OTTD2FS(const char *name) {return name;}

314
src/os/unix/unix.cpp Normal file
View File

@@ -0,0 +1,314 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file unix.cpp Implementation of Unix specific file handling. */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../variables.h"
#include "../../textbuf_gui.h"
#include "../../functions.h"
#include "../../core/random_func.hpp"
#include "table/strings.h"
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
#include <signal.h>
#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__)
#define HAS_STATVFS
#endif
#ifdef HAS_STATVFS
#include <sys/statvfs.h>
#endif
#ifdef __MORPHOS__
#include <exec/types.h>
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
/* The system supplied definition of SIG_IGN does not match */
#undef SIG_IGN
#define SIG_IGN (void (*)(int))1
#endif /* __MORPHOS__ */
#ifdef __AMIGA__
#warning add stack symbol to avoid that user needs to set stack manually (tokai)
// ULONG __stack =
#endif
#if defined(__APPLE__)
#if defined(WITH_SDL)
/* the mac implementation needs this file included in the same file as main() */
#include <SDL.h>
#endif
#endif
bool FiosIsRoot(const char *path)
{
#if !defined(__MORPHOS__) && !defined(__AMIGAOS__)
return path[1] == '\0';
#else
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
const char *s = strchr(path, ':');
return s != NULL && s[1] == '\0';
#endif
}
void FiosGetDrives()
{
return;
}
bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
{
uint64 free = 0;
#ifdef HAS_STATVFS
# ifdef __APPLE__
/* OSX 10.3 lacks statvfs so don't try to use it even though later versions of OSX has it. */
if (MacOSVersionIsAtLeast(10, 4, 0))
# endif
{
struct statvfs s;
if (statvfs(path, &s) != 0) return false;
free = (uint64)s.f_frsize * s.f_bavail;
}
#endif
if (tot != NULL) *tot = free;
return true;
}
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
{
char filename[MAX_PATH];
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
if (FiosIsRoot(path)) {
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
} else // XXX - only next line!
#else
assert(path[strlen(path) - 1] == PATHSEPCHAR);
if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
#endif
snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
return stat(filename, sb) == 0;
}
bool FiosIsHiddenFile(const struct dirent *ent)
{
return ent->d_name[0] == '.';
}
#ifdef WITH_ICONV
#include <iconv.h>
#include <errno.h>
#include "../../debug.h"
#include "../../string_func.h"
const char *GetCurrentLocale(const char *param);
#define INTERNALCODE "UTF-8"
/** Try and try to decipher the current locale from environmental
* variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable
* locale can be found, don't do any conversion "" */
static const char *GetLocalCode()
{
#if defined(__APPLE__)
return "UTF-8-MAC";
#else
/* Strip locale (eg en_US.UTF-8) to only have UTF-8 */
const char *locale = GetCurrentLocale("LC_CTYPE");
if (locale != NULL) locale = strchr(locale, '.');
return (locale == NULL) ? "" : locale + 1;
#endif
}
/** FYI: This is not thread-safe.
* convert between locales, which from and which to is set in the calling
* functions OTTD2FS() and FS2OTTD(). You should NOT use this function directly
* NOTE: iconv was added in OSX 10.3. 10.2.x will still have the invalid char
* issues. There aren't any easy fix for this */
static const char *convert_tofrom_fs(iconv_t convd, const char *name)
{
static char buf[1024];
/* Work around buggy iconv implementation where inbuf is wrongly typed as
* non-const. Correct implementation is at
* http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html */
#ifdef HAVE_BROKEN_ICONV
char *inbuf = (char*)name;
#else
const char *inbuf = name;
#endif
char *outbuf = buf;
size_t outlen = sizeof(buf) - 1;
size_t inlen = strlen(name);
strecpy(outbuf, name, outbuf + outlen);
iconv(convd, NULL, NULL, NULL, NULL);
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) {
DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno);
}
*outbuf = '\0';
/* FIX: invalid characters will abort conversion, but they shouldn't occur? */
return buf;
}
/** Convert from OpenTTD's encoding to that of the local environment
* @param name pointer to a valid string that will be converted
* @return pointer to a new stringbuffer that contains the converted string */
const char *OTTD2FS(const char *name)
{
static iconv_t convd = (iconv_t)(-1);
if (convd == (iconv_t)(-1)) {
const char *env = GetLocalCode();
convd = iconv_open(env, INTERNALCODE);
if (convd == (iconv_t)(-1)) {
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env);
return name;
}
}
return convert_tofrom_fs(convd, name);
}
/** Convert to OpenTTD's encoding from that of the local environment
* @param name pointer to a valid string that will be converted
* @return pointer to a new stringbuffer that contains the converted string */
const char *FS2OTTD(const char *name)
{
static iconv_t convd = (iconv_t)(-1);
if (convd == (iconv_t)(-1)) {
const char *env = GetLocalCode();
convd = iconv_open(INTERNALCODE, env);
if (convd == (iconv_t)(-1)) {
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE);
return name;
}
}
return convert_tofrom_fs(convd, name);
}
#else
const char *FS2OTTD(const char *name) {return name;}
const char *OTTD2FS(const char *name) {return name;}
#endif /* WITH_ICONV */
void ShowInfo(const char *str)
{
fprintf(stderr, "%s\n", str);
}
void ShowOSErrorBox(const char *buf, bool system)
{
#if defined(__APPLE__)
/* this creates an NSAlertPanel with the contents of 'buf'
* this is the native and nicest way to do this on OSX */
ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" );
#else
/* All unix systems, except OSX. Only use escape codes on a TTY. */
if (isatty(fileno(stderr))) {
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
} else {
fprintf(stderr, "Error: %s\n", buf);
}
#endif
}
#ifdef WITH_COCOA
void cocoaSetupAutoreleasePool();
void cocoaReleaseAutoreleasePool();
#endif
int CDECL main(int argc, char *argv[])
{
int ret;
#ifdef WITH_COCOA
cocoaSetupAutoreleasePool();
/* This is passed if we are launched by double-clicking */
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
argv[1] = NULL;
argc = 1;
}
#endif
SetRandomSeed(time(NULL));
signal(SIGPIPE, SIG_IGN);
ret = ttd_main(argc, argv);
#ifdef WITH_COCOA
cocoaReleaseAutoreleasePool();
#endif
return ret;
}
bool InsertTextBufferClipboard(Textbuf *tb)
{
return false;
}
/* multi os compatible sleep function */
#ifdef __AMIGA__
/* usleep() implementation */
# include <devices/timer.h>
# include <dos/dos.h>
extern struct Device *TimerBase = NULL;
extern struct MsgPort *TimerPort = NULL;
extern struct timerequest *TimerRequest = NULL;
#endif /* __AMIGA__ */
void CSleep(int milliseconds)
{
#if defined(PSP)
sceKernelDelayThread(milliseconds * 1000);
#elif defined(__BEOS__)
snooze(milliseconds * 1000);
#elif defined(__AMIGA__)
{
ULONG signals;
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
/* send IORequest */
TimerRequest->tr_node.io_Command = TR_ADDREQUEST;
TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000;
TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000;
SendIO((struct IORequest *)TimerRequest);
if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) {
AbortIO((struct IORequest *)TimerRequest);
}
WaitIO((struct IORequest *)TimerRequest);
}
#else
usleep(milliseconds * 1000);
#endif
}

266
src/os/windows/masm64.rules Normal file
View File

@@ -0,0 +1,266 @@
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
Name="Microsoft Macro Assembler 64"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="MASM AMD64"
DisplayName="Microsoft Macro Assembler for AMD64"
CommandLine="ml64.exe /c [AllOptions] [AdditionalOptions] /Ta[inputs]"
Outputs="[$ObjectFileName]"
FileExtensions="*.asm"
ExecutionDescription="Assembling..."
>
<Properties>
<BooleanProperty
Name="NoLogo"
DisplayName="Suppress Startup Banner"
Description="Suppress the display of the startup banner and information messages. (/nologo)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/nologo"
DefaultValue="true"
/>
<StringProperty
Name="ObjectFileName"
DisplayName="Object File Name"
PropertyPageName="Object File"
Description="Specifies the name of the output object file. (/Fo:[file])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Fo&quot;[value]&quot;"
DefaultValue="$(IntDir)\$(InputName).obj"
/>
<BooleanProperty
Name="PreserveIdentifierCase"
DisplayName="Preserve Identifier Case"
PropertyPageName="Identifiers"
Description="Preserves case of all user identifiers. (/Cp)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Cp"
/>
<BooleanProperty
Name="PreservePublicAndExternSymbolCase"
DisplayName="Preserve Public and Extern Symbol Case"
PropertyPageName="Identifiers"
Description="Preserves case in public and extern symbols. (/Cx)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Cx"
/>
<StringProperty
Name="PreprocessorDefinitions"
DisplayName="Preprocessor Definitions"
Description="Defines a text macro with the given name. (/D[symbol])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/D&quot;[value]&quot;"
Delimited="true"
Inheritable="true"
/>
<BooleanProperty
Name="GeneratePreprocessedSourceListing"
DisplayName="Generate Preprocessed Source Listing"
PropertyPageName="Listing File"
Description="Generates a preprocessed source listing to the Output Window. (/EP)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/EP"
/>
<StringProperty
Name="AssembledCodeListingFile"
DisplayName="Assembled Code Listing File"
PropertyPageName="Listing File"
Description="Generates an assembled code listing file. (/Fl[file])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Fl&quot;[value]&quot;"
/>
<StringProperty
Name="SourceBrowserFile"
DisplayName="Source Browser File"
PropertyPageName="Source Browser File"
Description="Generates a source browser .sbr file. (/Fr[file])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Fr&quot;[value]&quot;"
/>
<StringProperty
Name="ExtendedSourceBrowserFile"
DisplayName="Extended Source Browser File"
PropertyPageName="Source Browser File"
Description="Generates an extended form of a source browser .sbr file. (/FR[file])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/FR&quot;[value]&quot;"
/>
<StringProperty
Name="IncludePaths"
DisplayName="Include Paths"
Description="Sets path for include file. A maximum of 10 /I options is allowed. (/I [path])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/I &quot;[value]&quot;"
Delimited="true"
Inheritable="true"
/>
<BooleanProperty
Name="ListAllAvailableInformation"
DisplayName="List All Available Information"
PropertyPageName="Listing File"
Description="Turns on listing of all available information. (/Sa)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sa"
/>
<BooleanProperty
Name="AddInstructionTimings"
DisplayName="Add Instruction Timings"
PropertyPageName="Listing File"
Description="Adds instruction timings to listing file. (/Sc)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sc"
/>
<BooleanProperty
Name="AddFirstPassListing"
DisplayName="Add First Pass Listing"
PropertyPageName="Listing File"
Description="Adds first-pass listing to listing file. (/Sf)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sf"
/>
<IntegerProperty
Name="SourceListingLineWidth"
DisplayName="Source Listing Line Width"
PropertyPageName="Listing File"
Description="Sets the line width of source listing in characters per line. Range is 60 to 255 or 0. Default is 0. Same as PAGE width. (/Sl [width])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sl [value]"
/>
<BooleanProperty
Name="DisableSymbolTable"
DisplayName="Disable Symbol Table"
PropertyPageName="Listing File"
Description="Turns off symbol table when producing a listing. (/Sn)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sn"
/>
<IntegerProperty
Name="SourceListingPageLength"
DisplayName="Source Listing Page Length"
PropertyPageName="Listing File"
Description="Sets the page length of source listing in lines per page. Range is 10 to 255 or 0. Default is 0. Same as PAGE length. (/Sp [length])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sp [value]"
/>
<StringProperty
Name="SourceListingSubTitle"
DisplayName="Source Listing Subtitle"
PropertyPageName="Listing File"
Description="Specifies subtitle text for source listing. Same as SUBTITLE text. (/Ss [subtitle])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Ss [value]"
/>
<StringProperty
Name="SourceListingTitle"
DisplayName="Source Listing Title"
PropertyPageName="Listing File"
Description="Specifies title for source listing. Same as TITLE text. (/St [title])"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/St [value]"
/>
<BooleanProperty
Name="EnableFalseConditionalsInListing"
DisplayName="Enable False Conditionals In Listing"
PropertyPageName="Listing File"
Description="Turns on false conditionals in listing. (/Sx)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Sx"
/>
<EnumProperty
Name="WarningLevel"
DisplayName="Warning Level"
Description="Sets the warning level, where level = 0, 1, 2, or 3. (/W0, /W1, /W2, /W3)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
>
<Values>
<EnumValue
Value="0"
Switch="/W0"
DisplayName="Warning Level 0 (/W0)"
/>
<EnumValue
Value="1"
Switch="/W1"
DisplayName="Warning Level 1 (/W1)"
/>
<EnumValue
Value="2"
Switch="/W2"
DisplayName="Warning Level 2 (/W2)"
/>
<EnumValue
Value="3"
Switch="/W3"
DisplayName="Warning Level 3 (/W3)"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="TreatWarningsAsErrors"
DisplayName="Treat Warnings As Errors"
Description="Returns an error code if warnings are generated. (/WX)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/WX"
/>
<BooleanProperty
Name="GenerateLineInformation"
DisplayName="Generate Line Information"
PropertyPageName="Object File"
Description="Generates line-number information in object file. (/Zd)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Zd"
/>
<BooleanProperty
Name="MakeAllSymbolsPublic"
DisplayName="Make All Symbols Public"
PropertyPageName="Object File"
Description="Makes all symbols public. (/Zf)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Zf"
/>
<BooleanProperty
Name="GenerateCodeViewInformation"
DisplayName="Generate CodeView Information"
PropertyPageName="Object File"
Description="Generates CodeView information in object file. (/Zi)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Zi"
/>
<EnumProperty
Name="PackAlignmentBoundary"
DisplayName="Pack Alignment Boundary"
PropertyPageName="Advanced"
Description="Packs structures on the specified byte boundary. The alignment can be 1, 2, or 4. (/Zp1, /Zp2, /Zp4)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
>
<Values>
<EnumValue
Value="0"
Switch="/Zp1"
DisplayName="One Byte Boundary (/Zp1)"
/>
<EnumValue
Value="1"
Switch="/Zp2"
DisplayName="Two Byte Boundary (/Zp2)"
/>
<EnumValue
Value="2"
Switch="/Zp4"
DisplayName="Four Byte Boundary (/Zp4)"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="PerformSyntaxCheckOnly"
DisplayName="Perform Syntax Check Only"
Description="Performs a syntax check only. (/Zs)"
HelpURL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp"
Switch="/Zs"
/>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>

View File

@@ -0,0 +1,111 @@
//Microsoft Developer Studio generated resource script.
// $Id$
//
// This file is part of OpenTTD.
// OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
// OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
//
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_READONLY_SYMBOLS
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#ifdef MSVC
#include "winres.h"
#else
#define IDC_STATIC (-1) // all static controls
#endif
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral (Default) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
100 ICON DISCARDABLE "../media/openttd.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
100 DIALOG DISCARDABLE 0, 0, 305, 77
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Fatal Application Failure"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "&Close",12,7,58,50,14
// PUSHBUTTON "&Submit report",14,81,58,68,14,WS_DISABLED
PUSHBUTTON "&Emergency save",13,155,58,68,14
PUSHBUTTON "",15,243,58,55,14
EDITTEXT 11,7,79,291,118,ES_MULTILINE | ES_READONLY | WS_VSCROLL |
WS_HSCROLL | NOT WS_TABSTOP
LTEXT "",10,36,7,262,43
ICON 100,IDC_STATIC,9,9,20,20
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,8,0,!!REVISION!!
PRODUCTVERSION 0,8,0,!!REVISION!!
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "This program is licensed under the GNU General Public License.\0"
VALUE "CompanyName", "OpenTTD Development Team\0"
VALUE "FileDescription", "OpenTTD\0"
VALUE "FileVersion", "Development !!VERSION!!\0"
VALUE "InternalName", "openttd\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-2009. All Rights Reserved.\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "openttd.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "OpenTTD\0"
VALUE "ProductVersion", "Development !!VERSION!!\0"
VALUE "SpecialBuild", "-\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#endif // !_MAC
#endif // Neutral (Default) resources
/////////////////////////////////////////////////////////////////////////////

1378
src/os/windows/win32.cpp Normal file

File diff suppressed because it is too large Load Diff

55
src/os/windows/win32.h Normal file
View File

@@ -0,0 +1,55 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file win32.h declarations of functions for MS windows systems */
#ifndef WIN32_H
#define WIN32_H
#include <windows.h>
bool MyShowCursor(bool show);
typedef void (*Function)(int);
bool LoadLibraryList(Function proc[], const char *dll);
char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen);
wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen);
/* Function shortcuts for UTF-8 <> UNICODE conversion. When unicode is not
* defined these macros return the string passed to them, with UNICODE
* they return a pointer to the converted string. The only difference between
* XX_TO_YY and XX_TO_YY_BUFFER is that with the buffer variant you can
* specify where to put the converted string (and how long it can be). Without
* the buffer and internal buffer is used, of max 512 characters */
#if defined(UNICODE)
# define MB_TO_WIDE(str) OTTD2FS(str)
# define MB_TO_WIDE_BUFFER(str, buffer, buflen) convert_to_fs(str, buffer, buflen)
# define WIDE_TO_MB(str) FS2OTTD(str)
# define WIDE_TO_MB_BUFFER(str, buffer, buflen) convert_from_fs(str, buffer, buflen)
#else
extern uint _codepage; // local code-page in the system @see win32_v.cpp:WM_INPUTLANGCHANGE
# define MB_TO_WIDE(str) (str)
# define MB_TO_WIDE_BUFFER(str, buffer, buflen) (str)
# define WIDE_TO_MB(str) (str)
# define WIDE_TO_MB_BUFFER(str, buffer, buflen) (str)
#endif
/* Override SHGetFolderPath with our custom implementation */
#if defined(SHGetFolderPath)
#undef SHGetFolderPath
#endif
#define SHGetFolderPath OTTDSHGetFolderPath
HRESULT OTTDSHGetFolderPath(HWND, int, HANDLE, DWORD, LPTSTR);
#if defined(__MINGW32__)
#define SHGFP_TYPE_CURRENT 0
#endif /* __MINGW32__ */
#endif /* WIN32_H */

8
src/os/windows/win64.asm Normal file
View File

@@ -0,0 +1,8 @@
.CODE
PUBLIC _get_safe_esp
_get_safe_esp:
MOV RAX,RSP
RET
END