Externals - libsdl compiling, may not work
authorJohn Hodge <[email protected]>
Mon, 17 Jun 2013 11:15:48 +0000 (19:15 +0800)
committerJohn Hodge <[email protected]>
Mon, 17 Jun 2013 11:15:48 +0000 (19:15 +0800)
Externals/sdl12/.gitignore [new file with mode: 0644]
Externals/sdl12/Makefile
Externals/sdl12/patches/configure.in.patch
Externals/sdl12/patches/src/video/SDL_sysvideo.h.patch [new file with mode: 0644]
Externals/sdl12/patches/src/video/SDL_video.c.patch [new file with mode: 0644]
Externals/sdl12/patches/src/video/acess/ptyvideo.c [new file with mode: 0644]

diff --git a/Externals/sdl12/.gitignore b/Externals/sdl12/.gitignore
new file mode 100644 (file)
index 0000000..60065cd
--- /dev/null
@@ -0,0 +1 @@
+SDL-*
index 96acd04..6ee50f8 100644 (file)
@@ -7,7 +7,7 @@ DEPS :=
 TARBALL_PATTERN := SDL-*.tar.gz
 TARBALL_TO_DIR_L := %.tar.gz
 TARBALL_TO_DIR_R := %
-PATCHES := configure.in
+PATCHES := configure.in src/video/acess/ptyvideo.c src/video/SDL_video.c src/video/SDL_sysvideo.h
 CONFIGURE_ARGS = 
 AUTORECONF = yes
 
index 3507a9c..df2154d 100644 (file)
  dnl Detect the canonical build and host environments
  AC_CONFIG_AUX_DIR([build-scripts])
  dnl AC_CANONICAL_HOST
-@@ -2831,6 +2972,17 @@
+@@ -2831,6 +2972,16 @@
          # The RISC OS platform requires special setup.
          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
          ;;
 +        if test x$enable_video = xyes; then
 +            AC_DEFINE(SDL_VIDEO_DRIVER_ACESS)
 +            SOURCES="$SOURCES $srcdir/src/video/acess/*.c"
-+            SOURCES="$SOURCES $srcdir/src/video/acess/*.S"
 +            have_video=yes
 +        fi
 +       # TODO: Joystick
diff --git a/Externals/sdl12/patches/src/video/SDL_sysvideo.h.patch b/Externals/sdl12/patches/src/video/SDL_sysvideo.h.patch
new file mode 100644 (file)
index 0000000..9b6e364
--- /dev/null
@@ -0,0 +1,13 @@
+--- SDL-1.2.15_orig/src/video/SDL_sysvideo.h    2013-06-17 09:54:34.237122843 +0800
++++ SDL-1.2.15/src/video/SDL_sysvideo.h 2013-06-17 18:08:46.367186772 +0800
+@@ -410,6 +410,10 @@
+ #if SDL_VIDEO_DRIVER_CACA
+ extern VideoBootStrap CACA_bootstrap;
+ #endif
++#if SDL_VIDEO_DRIVER_ACESS
++extern VideoBootStrap AcessPTY_bootstrap;
++extern VideoBootStrap AcessAxWin_bootstrap;
++#endif
+ #if SDL_VIDEO_DRIVER_DUMMY
+ extern VideoBootStrap DUMMY_bootstrap;
+ #endif
diff --git a/Externals/sdl12/patches/src/video/SDL_video.c.patch b/Externals/sdl12/patches/src/video/SDL_video.c.patch
new file mode 100644 (file)
index 0000000..e3c5c46
--- /dev/null
@@ -0,0 +1,15 @@
+--- SDL-1.2.15_orig/src/video/SDL_video.c       2013-06-17 09:54:34.265134457 +0800
++++ SDL-1.2.15/src/video/SDL_video.c    2013-06-17 16:10:04.181159182 +0800
+@@ -126,6 +126,10 @@
+ #if SDL_VIDEO_DRIVER_CACA
+        &CACA_bootstrap,
+ #endif
++#if SDL_VIDEO_DRIVER_ACESS
++       //&AcessAxWin_bootstrap,
++       &AcessPTY_bootstrap,
++#endif
+ #if SDL_VIDEO_DRIVER_DUMMY
+        &DUMMY_bootstrap,
+ #endif
+
+
diff --git a/Externals/sdl12/patches/src/video/acess/ptyvideo.c b/Externals/sdl12/patches/src/video/acess/ptyvideo.c
new file mode 100644 (file)
index 0000000..4672b9c
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Acess2 SDL Video Driver
+ * - By John Hodge (thePowersGang)
+ * 
+ * video/acess/ptyvideo.c
+ * - PTY-based video driver
+ */
+#include "SDL_config.h"
+#include <acess/sys.h>
+#include <acess/devices/pty.h>
+#include "SDL_video.h"
+#include "../SDL_sysvideo.h"
+
+#define _THIS SDL_VideoDevice *this
+#define HIDDEN (this->hidden)
+
+// === TYPES ===
+struct SDL_PrivateVideoData
+{
+        int    OutFD;
+       SDL_Rect        MaxRect;
+       SDL_Rect        *FullscreenModes[2];
+       Uint32  *Palette;       // 256 colours
+};
+
+// === PROTOTYPES ===
+static int AcessPTY_Avaliable(void);
+static SDL_VideoDevice *AcessPTY_Create(int devidx);
+static void AcessPTY_Destroy(SDL_VideoDevice *device);
+// - Core functions
+static int     AcessPTY_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect        **AcessPTY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *AcessPTY_SetVideoMode(_THIS, SDL_Surface *Current, int W, int H, int BPP, Uint32 Flags);
+static int     AcessPTY_SetColors(_THIS, int FirstColour, int NColours, SDL_Color *Colours);
+static void    AcessPTY_VideoQuit(_THIS);
+static void    AcessPTY_UpdateRects(_THIS, int NumRects, SDL_Rect *Rects);
+// - Hardware Surfaces (TODO)
+//static int   AcessPTY_AllocHWSurface(_THIS, SDL_Surface *Surface);
+//static int   AcessPTY_FillHWRect(_THIS, SDL_Surface *Dst, SDL_Rect *Rect, Uint32 Color);
+
+// === GLOBALS ===
+VideoBootStrap AcessPTY_bootstrap = {
+       "acesspty", "Acess2 PTY Video",
+       AcessPTY_Avaliable, AcessPTY_Create
+};
+SDL_VideoDevice        AcessPTY_TemplateDevice = {
+       .VideoInit      = AcessPTY_VideoInit,
+       .ListModes      = AcessPTY_ListModes,
+       .SetVideoMode   = AcessPTY_SetVideoMode,
+       .SetColors      = AcessPTY_SetColors,
+       .VideoQuit      = AcessPTY_VideoQuit,
+       .UpdateRects    = AcessPTY_UpdateRects,
+       //.FillHWRect = AcessPTY_FillHWRect,
+       .free   = AcessPTY_Destroy
+};
+
+int AcessPTY_Avaliable(void)
+{
+       // - test on stdin so stdout can be redirected without breaking stuff
+       if( _SysIOCtl(0, DRV_IOCTL_TYPE, NULL) != DRV_TYPE_TERMINAL )
+               return 0;
+       // TODO: Check if the terminal supports graphics modes
+       return 1;
+}
+
+SDL_VideoDevice        *AcessPTY_Create(int devidx)
+{
+       SDL_VideoDevice *ret;
+
+       // Allocate and pre-populate
+       ret = malloc( sizeof(SDL_VideoDevice) );
+       if( !ret ) {
+               SDL_OutOfMemory();
+               return NULL;
+       }
+       memcpy(ret, &AcessPTY_TemplateDevice, sizeof(SDL_VideoDevice));
+       ret->hidden = malloc( sizeof(struct SDL_PrivateVideoData) );
+       if( !ret->hidden ) {
+               SDL_OutOfMemory();
+               free(ret);
+               return NULL;
+       }
+       memset(ret->hidden, 0, sizeof(*ret->hidden));
+
+       ret->hidden->OutFD = _SysCopyFD(0, -1);
+       if( ret->hidden->OutFD == -1 ) {
+               free(ret->hidden);
+               free(ret);
+               return NULL;
+       }
+
+       // Redirect stdout/stderr if they point to the terminal
+       if( 1 ) { //_SysIsSameNode(0, 1) ) {
+               _SysReopen(1, "stdout.txt", OPENFLAG_WRITE);
+       }
+       if( 1 ) { //_SysIsSameNode(0, 2) ) {
+               _SysReopen(2, "stderr.txt", OPENFLAG_WRITE);
+       }
+
+       return ret;
+}
+
+void AcessPTY_Destroy(SDL_VideoDevice *device)
+{
+       _SysClose(device->hidden->OutFD);
+       free(device->hidden);
+       free(device);
+}
+
+// ---
+// General functions
+// ---
+int AcessPTY_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+       // Set PTY to graphics mode
+       struct ptymode mode = {.OutputMode = PTYBUFFMT_FB, .InputMode = PTYIMODE_RAW};
+       _SysIOCtl(HIDDEN->OutFD, PTY_IOCTL_SETMODE, &mode);
+
+       // Get current dimensions (and use these as the max)
+       // - Not strictly true when using a GUI Terminal, but does apply for VTerms
+       struct ptydims  dims;
+       _SysIOCtl(HIDDEN->OutFD, PTY_IOCTL_GETDIMS, &dims);
+       
+       HIDDEN->MaxRect.x = 0;
+       HIDDEN->MaxRect.y = 0;
+       HIDDEN->MaxRect.w = dims.PW;
+       HIDDEN->MaxRect.h = dims.PH;
+       
+       HIDDEN->FullscreenModes[0] = &HIDDEN->MaxRect;
+       HIDDEN->FullscreenModes[1] = NULL;
+       
+       return 0;
+}
+
+SDL_Rect **AcessPTY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+       if( flags & SDL_FULLSCREEN)
+               return HIDDEN->FullscreenModes; // Should be only one entry
+//     else if( SDLToDFBPixelFormat (format) != DSPF_UNKNOWN )
+               return (SDL_Rect**) -1;
+//     else
+//             return NULL;
+}
+
+SDL_Surface *AcessPTY_SetVideoMode(_THIS, SDL_Surface *Current, int W, int H, int BPP, Uint32 Flags)
+{
+       // Sanity first
+       if( W <= 0 || W > HIDDEN->MaxRect.w )
+               return NULL;
+       if( H <= 0 || H > HIDDEN->MaxRect.h )
+               return NULL;
+
+       struct ptydims dims = {.PW = W, .PH = H};
+       _SysIOCtl(HIDDEN->OutFD, PTY_IOCTL_SETDIMS, &dims);
+
+       Current->pixels = SDL_malloc(W * H * 4);
+       if( !Current->pixels ) {
+               
+       }
+       
+       return Current;
+}
+
+int AcessPTY_SetColors(_THIS, int FirstColour, int NColours, SDL_Color *Colours)
+{
+       return 1;
+}
+
+void AcessPTY_VideoQuit(_THIS)
+{
+}
+
+void AcessPTY_UpdateRects(_THIS, int NumRects, SDL_Rect *Rects)
+{
+        int    w = this->screen->w;
+        int    h = this->screen->h;
+       _SysWrite(HIDDEN->OutFD, w*h*4, this->screen->pixels);
+}
+

UCC git Repository :: git.ucc.asn.au