From 80f88fe2a0a444ca5081b9820da5788278f21ed7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 17 Jun 2013 19:15:48 +0800 Subject: [PATCH] Externals - libsdl compiling, may not work --- Externals/sdl12/.gitignore | 1 + Externals/sdl12/Makefile | 2 +- Externals/sdl12/patches/configure.in.patch | 3 +- .../patches/src/video/SDL_sysvideo.h.patch | 13 ++ .../sdl12/patches/src/video/SDL_video.c.patch | 15 ++ .../sdl12/patches/src/video/acess/ptyvideo.c | 179 ++++++++++++++++++ 6 files changed, 210 insertions(+), 3 deletions(-) create mode 100644 Externals/sdl12/.gitignore create mode 100644 Externals/sdl12/patches/src/video/SDL_sysvideo.h.patch create mode 100644 Externals/sdl12/patches/src/video/SDL_video.c.patch create mode 100644 Externals/sdl12/patches/src/video/acess/ptyvideo.c diff --git a/Externals/sdl12/.gitignore b/Externals/sdl12/.gitignore new file mode 100644 index 00000000..60065cd6 --- /dev/null +++ b/Externals/sdl12/.gitignore @@ -0,0 +1 @@ +SDL-* diff --git a/Externals/sdl12/Makefile b/Externals/sdl12/Makefile index 96acd04e..6ee50f87 100644 --- a/Externals/sdl12/Makefile +++ b/Externals/sdl12/Makefile @@ -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 diff --git a/Externals/sdl12/patches/configure.in.patch b/Externals/sdl12/patches/configure.in.patch index 3507a9ca..df2154d7 100644 --- a/Externals/sdl12/patches/configure.in.patch +++ b/Externals/sdl12/patches/configure.in.patch @@ -148,7 +148,7 @@ 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" ;; @@ -158,7 +158,6 @@ + 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 index 00000000..9b6e3645 --- /dev/null +++ b/Externals/sdl12/patches/src/video/SDL_sysvideo.h.patch @@ -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 index 00000000..e3c5c467 --- /dev/null +++ b/Externals/sdl12/patches/src/video/SDL_video.c.patch @@ -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 index 00000000..4672b9c6 --- /dev/null +++ b/Externals/sdl12/patches/src/video/acess/ptyvideo.c @@ -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 +#include +#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); +} + -- 2.20.1