From 57fc5831d37e6f0a14175a3aa26ce66dea78724f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Sch=C2=84fer?= Date: Sat, 29 Mar 2025 10:35:37 +0100 Subject: [PATCH] Some OS/2 specific changes. Patches are not complete yet --- build-os2.cmd | 5 +++++ configure.ac | 5 +++-- include/byteorder.h | 2 +- include/ioapi.h | 2 +- include/np2glue.h | 2 +- src/dos/dos_programs.cpp | 5 ++++- src/dos/drive_cache.cpp | 4 ++-- src/dos/drive_local.cpp | 2 ++ src/gui/sdl_mapper.cpp | 5 ++++- src/libs/physfs/physfs_platform_os2.c | 18 +++++++++--------- 10 files changed, 32 insertions(+), 18 deletions(-) diff --git a/build-os2.cmd b/build-os2.cmd index fbe8b2237..77c5eedf4 100644 --- a/build-os2.cmd +++ b/build-os2.cmd @@ -1,4 +1,9 @@ echo off bash autogen.sh dash configure +REM since cpu cores need a lot of memory, +REM we don't want to build parallel +cd src\cpu +make +cd ..\.. make -j4 diff --git a/configure.ac b/configure.ac index ae96cd630..40eec20a1 100644 --- a/configure.ac +++ b/configure.ac @@ -372,8 +372,9 @@ fi dnl Some needed libraries for OS2 dnl perhaps join this with the other target depended checks. move them upwards if test x$host = xi386-pc-os2-emx ; then - CXXFLAGS="$CXXFLAGS -Zmt" - LDFLAGS="$LDFLAGS -Zomf -Zmt" + CXXFLAGS="$CXXFLAGS -DOS2 -march=pentium4 -idirafter /@unixroot/usr/include/os2tk45" + CFLAGS="$CFLAGS -DOS2 -march=pentium4 -idirafter /@unixroot/usr/include/os2tk45" + LDFLAGS="$LDFLAGS -Zomf -Zhigh-mem -lcx" fi dnl I would like to know of any concerns given by the C++ compiler. diff --git a/include/byteorder.h b/include/byteorder.h index c91c16bfa..cf6ab341a 100644 --- a/include/byteorder.h +++ b/include/byteorder.h @@ -132,7 +132,7 @@ #define be64toh(x) betoh64(x) #define le64toh(x) letoh64(x) -#elif defined(__HAIKU__) +#elif defined(__HAIKU__) || defined(OS2) #include diff --git a/include/ioapi.h b/include/ioapi.h index 0bc6904ff..b16ae6cce 100644 --- a/include/ioapi.h +++ b/include/ioapi.h @@ -44,7 +44,7 @@ #include #include "zlib.h" -#if defined(__APPLE__) || defined(USE_FILE32API) +#if defined(__APPLE__) || defined(USE_FILE32API) || defined(OS2) #define fopen64 fopen #define ftello64 ftell #define fseeko64 fseek diff --git a/include/np2glue.h b/include/np2glue.h index 13565da1a..f6a9e5b5a 100644 --- a/include/np2glue.h +++ b/include/np2glue.h @@ -27,7 +27,7 @@ #define MAX_PATH PATH_MAX #endif -#ifdef WIN32 +#if defined(WIN32) || defined(OS2) # define BYTESEX_LITTLE # define _G_DIR_SEPARATOR '\\' #elif defined(EMSCRIPTEN) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index c41d192ff..ad6d65a88 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -133,6 +133,9 @@ bool CheckDBCSCP(int32_t codepage); #define INCL DOSFILEMGR #define INCL_DOSERRORS #include "os2.h" + +typedef char host_cnv_char_t; +host_cnv_char_t *CodePageGuestToHost(const char *s); #endif #if defined(WIN32) @@ -10302,7 +10305,7 @@ void DOS_SetupPrograms(void) { "Return Color #7 to the default color value\n\n SETCOLOR 3 +\n\n" "Return Color #3 to the preset color value\n\n SETCOLOR MONO\n\n" "Display current MONO mode status\n\n" - "To change the current background and foreground colors, use COLORPGM command.\n"); + "To change the current background and foreground colors, use COLOR command.\n"); MSG_Add("PROGRAM_SETCOLOR_STATUS","MONO mode status: %s (video mode %d)\n"); MSG_Add("PROGRAM_SETCOLOR_ACTIVE","active"); MSG_Add("PROGRAM_SETCOLOR_INACTIVE","inactive"); diff --git a/src/dos/drive_cache.cpp b/src/dos/drive_cache.cpp index 13b84ca22..797a90e15 100644 --- a/src/dos/drive_cache.cpp +++ b/src/dos/drive_cache.cpp @@ -156,9 +156,9 @@ void DOS_Drive_Cache::SetBaseDir(const char* baseDir, DOS_Drive *drive) { #else // OS2 //TODO determine whether cdrom or not! FSINFO fsinfo; - ULONG drivenumber = drive[0]; + ULONG drivenumber = drives[0]; if (drivenumber > 26) { // drive letter was lowercase - drivenumber = drive[0] - 'a' + 1; + drivenumber = drives[0] - 'a' + 1; } APIRET rc = DosQueryFSInfo(drivenumber, FSIL_VOLSER, &fsinfo, sizeof(FSINFO)); if (rc == NO_ERROR) { diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index ff5cb8ccf..bad32d61f 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -2995,6 +2995,8 @@ bool LocalFile::Close() { extern int errno; LOG_MSG("Set time failed (%s)", strerror(errno)); } +#elif defined(OS2) + LOG_MSG("File set time TBD"); #elif !defined(RISCOS) // Linux (TODO: What about Mac OS X/Darwin?) // NTS: Do not attempt futime, Linux doesn't have it. // Do not attempt futimes, Linux man pages LIE about having it. It's even there in the freaking header, but not recognized! diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 52cb83bee..cf5b834bd 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -1033,10 +1033,13 @@ static SDLKey sdlkey_map[MAX_SCANCODES] = { // Convert hardware scancode (XKB = }; #else // !MACOSX && !Linux -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(OS2) // Todo: recheck sdl mapping #define SDLK_JP_RO (SDLKey)0x73 #define SDLK_JP_YEN (SDLKey)0x7d +#if defined(OS2) +#define SDLK_KP_COMMA SDLK_COMMA +#endif #endif #define MAX_SCANCODES 0xdf static SDLKey sdlkey_map[MAX_SCANCODES] = { diff --git a/src/libs/physfs/physfs_platform_os2.c b/src/libs/physfs/physfs_platform_os2.c index 8cc8044cf..84a728a8b 100644 --- a/src/libs/physfs/physfs_platform_os2.c +++ b/src/libs/physfs/physfs_platform_os2.c @@ -172,7 +172,7 @@ static char *cvtCodepageToUtf8(const char *cpstr) size_t cplen = len; size_t unilen = len; size_t subs = 0; - UniChar *uc2ptr = __PHYSFS_smallAlloc(len * sizeof (UniChar)); + UniChar *uc2ptr = (UniChar*)__PHYSFS_smallAlloc(len * sizeof (UniChar)); UniChar *uc2str = uc2ptr; BAIL_IF(!uc2ptr, PHYSFS_ERR_OUT_OF_MEMORY, NULL); @@ -268,9 +268,9 @@ static void prepUnicodeSupport(void) int ok = 0; char buf[CCHMAXPATH]; UniChar defstr[] = { 0 }; - if (DosLoadModule(buf, sizeof (buf) - 1, "uconv", &uconvdll) == NO_ERROR) + if (DosLoadModule((PSZ)buf, sizeof (buf) - 1, (PCSZ)"uconv", &uconvdll) == NO_ERROR) { - #define LOAD(x) (DosQueryProcAddr(uconvdll,0,#x,(PFN*)&p##x)==NO_ERROR) + #define LOAD(x) (DosQueryProcAddr(uconvdll,0,(PCSZ)#x,(PFN*)&p##x)==NO_ERROR) ok = LOAD(UniCreateUconvObject) && LOAD(UniFreeUconvObject) && LOAD(UniUconvToUcs) && @@ -284,7 +284,7 @@ static void prepUnicodeSupport(void) if (uconvdll) { if (uconv) - pUniFreeUconvObject(uconv); + pUniFreeUconvObject(&uconv); DosFreeModule(uconvdll); uconvdll = 0; } /* if */ @@ -303,7 +303,7 @@ void __PHYSFS_platformDeinit(void) { if (uconvdll) { - pUniFreeUconvObject(uconv); + pUniFreeUconvObject(&uconv); uconv = 0; DosFreeModule(uconvdll); uconvdll = 0; @@ -551,7 +551,7 @@ static HFILE openFile(const char *filename, const ULONG flags, const ULONG mode) BAIL_IF_ERRPASS(!cpfname, 0); - rc = DosOpen(cpfname, &hfile, &action, 0, FILE_NORMAL, flags, mode, NULL); + rc = DosOpen((PCSZ)cpfname, &hfile, &action, 0, FILE_NORMAL, flags, mode, NULL); allocator.Free(cpfname); BAIL_IF(rc != NO_ERROR, errcodeFromAPIRET(rc), 0); @@ -690,9 +690,9 @@ int __PHYSFS_platformDelete(const char *path) int retval = 0; BAIL_IF_ERRPASS(!cppath, 0); - rc = DosQueryPathInfo(cppath, FIL_STANDARD, &fs, sizeof (fs)); + rc = DosQueryPathInfo((PCSZ)cppath, FIL_STANDARD, &fs, sizeof (fs)); GOTO_IF(rc != NO_ERROR, errcodeFromAPIRET(rc), done); - rc = (fs.attrFile & FILE_DIRECTORY) ? DosDeleteDir(path) : DosDelete(path); + rc = (fs.attrFile & FILE_DIRECTORY) ? DosDeleteDir((PCSZ)path) : DosDelete((PCSZ)path); GOTO_IF(rc != NO_ERROR, errcodeFromAPIRET(rc), done); retval = 1; /* success */ @@ -730,7 +730,7 @@ int __PHYSFS_platformStat(const char *filename, PHYSFS_Stat *stat, const int fol BAIL_IF_ERRPASS(!cpfname, 0); - rc = DosQueryPathInfo(cpfname, FIL_STANDARD, &fs, sizeof (fs)); + rc = DosQueryPathInfo((PCSZ)cpfname, FIL_STANDARD, &fs, sizeof (fs)); GOTO_IF(rc != NO_ERROR, errcodeFromAPIRET(rc), done); if (fs.attrFile & FILE_DIRECTORY)