Skip to content
Permalink
Browse files

OS/2 port!

This was mostly, if not entirely, written by "Doodle" and "Caetano":
    doodle@scenergy.dfmk.hu
    daniel@caetano.eng.br

--ryan.
  • Loading branch information
icculus committed Nov 23, 2005
1 parent 63f6506 commit b4b5899abe79b768e381a51e5b4ab783810abfd7
Showing with 6,571 additions and 8 deletions.
  1. +133 −0 README.OS2
  2. +33 −0 Watcom.mif
  3. +2 −3 include/SDL_byteorder.h
  4. +43 −0 include/SDL_thread.h
  5. +1 −1 include/SDL_types.h
  6. +18 −0 include/begin_code.h
  7. +16 −0 setvars.cmd
  8. +132 −0 src/Makefile.wat
  9. +87 −0 src/SDL.c
  10. +2 −0 src/SDL_loadso.c
  11. +27 −0 src/audio/Makefile.wat
  12. +24 −0 src/audio/SDL_audio.c
  13. +6 −0 src/audio/SDL_mixer_MMX_VC.c
  14. +3 −0 src/audio/SDL_sysaudio.h
  15. +436 −0 src/audio/dart/SDL_dart.c
  16. +67 −0 src/audio/dart/SDL_dart.h
  17. +30 −0 src/cdrom/Makefile.wat
  18. +399 −0 src/cdrom/os2/SDL_syscdrom.c
  19. +27 −0 src/cpuinfo/Makefile.wat
  20. +24 −0 src/endian/Makefile.wat
  21. +24 −0 src/events/Makefile.wat
  22. +19 −0 src/events/SDL_events.c
  23. +5 −2 src/events/SDL_resize.c
  24. +4 −0 src/events/SDL_sysevents.h
  25. +24 −0 src/file/Makefile.wat
  26. +27 −0 src/joystick/Makefile.wat
  27. +669 −0 src/joystick/os2/SDL_sysjoystick.c
  28. +177 −0 src/joystick/os2/joyos2.h
  29. +1 −0 src/loadso/macosx/SDL_loadso.c
  30. +82 −0 src/loadso/os2/SDL_loadso.c
  31. +36 −0 src/thread/Makefile.wat
  32. +4 −0 src/thread/SDL_systhread.h
  33. +9 −1 src/thread/SDL_thread.c
  34. +223 −0 src/thread/os2/SDL_syscond.c
  35. +27 −0 src/thread/os2/SDL_syscond_c.h
  36. +115 −0 src/thread/os2/SDL_sysmutex.c
  37. +199 −0 src/thread/os2/SDL_syssem.c
  38. +114 −0 src/thread/os2/SDL_systhread.c
  39. +27 −0 src/thread/os2/SDL_systhread_c.h
  40. +27 −0 src/timer/Makefile.wat
  41. +1 −1 src/timer/SDL_timer.c
  42. +230 −0 src/timer/os2/SDL_systimer.c
  43. +27 −0 src/video/Makefile.wat
  44. +3 −0 src/video/SDL_sysvideo.h
  45. +6 −0 src/video/SDL_video.c
  46. +2,787 −0 src/video/os2fslib/SDL_os2fslib.c
  47. +63 −0 src/video/os2fslib/SDL_os2fslib.h
  48. +79 −0 src/video/os2fslib/SDL_vkeys.h
  49. +52 −0 test/Makefile.wat
@@ -0,0 +1,133 @@

===========
SDL on OS/2
===========

Last updated on Oct 02, 2005.


1. How to compile?
------------------

To compile this, you'll need the followings installed:
- The OS/2 Developer's Toolkit
- The OpenWatcom compiler
(http://www.openwatcom.org)
- The FSLib library
(ftp://ftp.netlabs.org/pub/SDL)

Please edit the second, fourth and fifth lines of setvars.cmd file
to set the folders where the toolkit, the OW compiler and the FSLib are.
You won't need NASM yet (The Netwide Assembler), you can leave that line.
Run setvars.cmd, and you should get a shell in which you can
compile SDL.

Check the "Watcom.mif" file. This is the file which is included by all the
Watcom makefiles, so changes here will affect the whole build process.
There is a line in there which determines if the resulting SDL.DLL will be
a 'debug' or a 'release' build. The 'debug' version is full of printf()'s,
so if something goes wrong, its output can help a lot for debugging.

Then go to the 'src' folder, and run "wmake -f makefile.wat".
This should create the SDL.DLL and the corresponding SDL.LIB file there.

To test applications, it's a good idea to use the 'debug' build of SDL, and
redirect the standard output and standard error output to files, to see what
happens internally in SDL.
(like: testsprite >stdout.txt 2>stderr.txt)

To rebuild SDL, use the following commands in 'src' folder:
wmake -f makefile.wat clean
wmake -f makefile.wat



2. How to compile the testapps?
-------------------------------

Once you have SDL.DLL compiled, navigate into the 'test' folder, copy in there
the newly built SDL.DLL, and copy in there FSLib.DLL.

Then run "wmake -f makefile.wat" in there to compile some of the testapps.



3. What is missing?
-------------------

The following things are missing from this SDL implementation:
- MMX, SSE and 3DNOW! optimized video blitters?
- HW Video surfaces
- OpenGL support



4. Special Keys / Full-Screen support
-------------------------------------

There are two special hot-keys implemented:
- Alt+Home switches between fullscreen and windowed mode
- Alt+End simulates closing the window (can be used as a Panic key)
Only the LEFT Alt key will work.



5. Joysticks on SDL/2
---------------------

The Joystick detection only works for standard joysticks (2 buttons, 2 axes
and the like). Therefore, if you use a non-standard joystick, you should
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
file or CONFIG.SYS, so SDL applications can provide full capability to your
device. The syntax is:

SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]

So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
the line should be:

SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0

If you want to add spaces in your joystick name, just surround it with
quotes or double-quotes:

SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0

or

SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0

Notive However that Balls and Hats are not supported under OS/2, and the
value will be ignored... but it is wise to define these correctly because
in the future those can be supported.
Also the number of buttons is limited to 2 when using two joysticks,
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
and 8 when using a joystick with 2 axes. Notice however these are limitations
of the Joystick Port hardware, not OS/2.



6. Next steps...
----------------

Things to do:
- Implement missing stuffs (look for 'TODO' string in source code!)
- Finish video driver (the 'wincommon' can be a good example for missing
things like application icon and so on...)
- Enable MMX/SSE/SSE2 acceleration functions
- Rewrite CDROM support using DOS Ioctl for better support.



7. Contacts
-----------

You can contact the developers for bugs:

Area Developer email
General (Audio/Video/System) Doodle doodle@scenergy.dfmk.hu
CDROM and Joystick Caetano daniel@caetano.eng.br

Notice however that SDL/2 is 'in development' stage so ... if you want to help,
please, be our guest and contact us!

@@ -0,0 +1,33 @@
#=============================================================================
# This file contains the common includes for the
# Watcom makefiles to build SDL.DLL for OS/2
#
#
#=============================================================================

# Create debug build or not?
#debug_build=defined

# Special flags for building SDL
SDLCFlags = -dBUILD_SDL -dCHECK_LEAKS

#
#==============================================================================
#

!ifdef debug_build
debugflags = -d2 -dDEBUG_BUILD
!else
debugflags =
!endif

cflags = -zq $(debugflags) -bd -bm -bt=OS2 -5s -fpi -sg -otexan -wx -ei $(SDLCFlags) $(ExtraCFlags)

.extensions:
.extensions: .lib .dll .obj .c .asm

.c.obj : .AUTODEPEND
wcc386 $[* $(cflags)

.asm.obj : .AUTODEPEND
nasm -t -O2 -f obj -I$(%include) $[*.asm
@@ -55,9 +55,8 @@ static char rcsid =
(defined(__arm__) || defined(__thumb__)) || \
(defined(__sh__) || defined(__sh64__)) || \
(defined(__mips__) && defined(__MIPSEL__)) || \
defined(__SYMBIAN32__) || \
defined(__x86_64__) || \
defined(__LITTLE_ENDIAN__)
defined(__SYMBIAN32__) || defined(__x86_64__) || \
defined(__OS2__) || defined(__LITTLE_ENDIAN__)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#else
#define SDL_BYTEORDER SDL_BIG_ENDIAN
@@ -50,7 +50,50 @@ struct SDL_Thread;
typedef struct SDL_Thread SDL_Thread;

/* Create a thread */
#ifdef __OS2__
/*
We compile SDL into a DLL on OS/2. This means, that it's the DLL which
creates a new thread for the calling process with the SDL_CreateThread()
API. There is a problem with this, that only the RTL of the SDL.DLL will
be initialized for those threads, and not the RTL of the calling application!
To solve this, we make a little hack here.
We'll always use the caller's _beginthread() and _endthread() APIs to
start a new thread. This way, it it's the SDL.DLL which uses this API,
then the RTL of SDL.DLL will be used to create the new thread, and if it's
the application, then the RTL of the application will be used.
So, in short:
Always use the _beginthread() and _endthread() of the calling runtime library!
*/

#ifdef __WATCOMC__
#include <process.h> // This has _beginthread() and _endthread() defined!
#endif
#ifdef __EMX__
#include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
#endif

typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam);
typedef void SDLCALL (*pfnSDL_CurrentEndThread)(void);

extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);

// Disable warnings about unreferenced symbol!
#pragma disable_message (202)
static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam)
{
return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam);
}

static void SDLCALL SDL_CurrentEndThread(void)
{
_endthread();
}

#define SDL_CreateThread(fn, data) SDL_CreateThread_Core(fn, data, SDL_CurrentBeginThread, SDL_CurrentEndThread)

#else
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
#endif

/* Get the 32-bit thread identifier for the current thread */
extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
@@ -57,7 +57,7 @@ typedef signed int Sint32;
#if !defined(__STRICT_ANSI__)
#ifdef __osf__ /* Tru64 */
#define SDL_HAS_64BIT_TYPE long
#elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DECC)
#elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DECC) || defined(__WATCOMC__)
#define SDL_HAS_64BIT_TYPE long long
#elif defined(_MSC_VER) /* VC++ */
#define SDL_HAS_64BIT_TYPE __int64
@@ -56,18 +56,36 @@
# define DECLSPEC __declspec(dllexport)
# endif
# else
# ifdef __OS2__
# ifdef __WATCOMC__
# ifdef BUILD_SDL
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC
# endif
# else
# define DECLSPEC
# endif
# else
# define DECLSPEC
# endif
# endif
# endif
#endif

/* By default SDL uses the C calling convention */
#ifndef SDLCALL
#if defined(WIN32) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
#ifdef __OS2__
/* But on OS/2, we use the _System calling convention */
/* to be compatible with every compiler */
#define SDLCALL _System
#else
#define SDLCALL
#endif
#endif
#endif /* SDLCALL */

/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
@@ -0,0 +1,16 @@
@ECHO OFF
SET WATCOM=d:\watcom
SET NASM=d:\nasm
SET OS2TK=d:\os2tk45
SET FSLIB=d:\watcom\projects\FSLib

SET PATH=%WATCOM%\BINP;%WATCOM%\BINW;%os2tk%\bin;%NASM%;%PATH%
SET INCLUDE=%WATCOM%\H;%WATCOM%\H\OS2
SET FINCLUDE=%WATCOM%\SRC\FORTRAN
SET EDPATH=%WATCOM%\EDDAT
SET HELP=%WATCOM%\BINP\HELP;%HELP%
SET BOOKSHELF=%WATCOM%\BINP\HELP;%BOOKSHELF%
SET BEGINLIBPATH=%WATCOM%\BINP\DLL

cmd

0 comments on commit b4b5899

Please sign in to comment.