changeset 21:f0869ef0f2d9

Add commandline settings for fullscreen and changing horiz/vert resolution of SDL output. Also hide the mouse cursor.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 23 May 2010 20:06:17 +0300
parents ce32734b8bdd
children 885458f0d56e
files pwplib/pwplib.h pwplib/sdl.c pwplib/setup.c
diffstat 3 files changed, 38 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pwplib/pwplib.h	Sun May 23 19:46:04 2010 +0300
+++ b/pwplib/pwplib.h	Sun May 23 20:06:17 2010 +0300
@@ -102,7 +102,7 @@
    
    int(*timerfunc)();
 
-   int setup[20];
+   int setup[128];
    
    struct
    {
@@ -146,7 +146,11 @@
   SETUP_SHUTUP,
   SETUP_USERHEIGHT,
   SETUP_USERWIDTH,
-  SETUP_WANTHELP
+  SETUP_WANTHELP,
+  
+  SETUP_FULLSCREEN,
+  SETUP_XRES,
+  SETUP_YRES
 };
 
 #ifndef __PWPLIB_C
@@ -156,10 +160,10 @@
 
 typedef struct
 {
-   char*name;
+   char *name;
    int type;
-   void*dflt;
-   void**var;
+   void *dflt;
+   void **var;
 }optab;
 
 #define OPT_BIN     0
--- a/pwplib/sdl.c	Sun May 23 19:46:04 2010 +0300
+++ b/pwplib/sdl.c	Sun May 23 20:06:17 2010 +0300
@@ -100,9 +100,14 @@
     int i;
 
     /* Assume these settings for now */
-    pwp_SDL.vflags = 0;
-    pwp_SDL.width = 640;
-    pwp_SDL.height = 480;
+    pwp_SDL.vflags = pwplib.setup[SETUP_FULLSCREEN] ? SDL_FULLSCREEN : 0;
+    pwp_SDL.width = pwplib.setup[SETUP_XRES];
+    pwp_SDL.height = pwplib.setup[SETUP_YRES];
+
+    if (pwp_SDL.width < 8 || pwp_SDL.height < 16) {
+        pwpwrite("* invalid xres or yres (%d x %d)\n", pwp_SDL.width, pwp_SDL.height);
+        return 0;
+    }
 
     /* Set pwplib internal parameters */
     pwplib.videobuf.width = pwp_SDL.width / 4;
@@ -111,16 +116,16 @@
 
     /* Initialize a indexed / paletted video surface */
     pwp_SDL.screen = SDL_SetVideoMode(pwp_SDL.width, pwp_SDL.height, 8, pwp_SDL.vflags);
-    if (pwp_SDL.screen == NULL)
-    {
+    if (pwp_SDL.screen == NULL) {
         pwpwrite("* SDL could not initialize video surface/mode.\n");
         return 0;
     }
     
     fprintf(stderr, "\nSDL_surface: %d x %d, pitch=%d\n", pwp_SDL.screen->w, pwp_SDL.screen->h, pwp_SDL.screen->pitch);
     
-    /* Set window caption, if any */
+    /* Set window caption, if any, hide mouse cursor */
     SDL_WM_SetCaption(PWP_WINNAME, PWP_WINNAME);
+    SDL_ShowCursor(0);
 
     /* Generate palette and rasterization lookup table */
     for (i = 0; i < PWP_NCOLORS; i++)
--- a/pwplib/setup.c	Sun May 23 19:46:04 2010 +0300
+++ b/pwplib/setup.c	Sun May 23 20:06:17 2010 +0300
@@ -259,6 +259,12 @@
    "audev",  OPT_STRING,(void*)NULL,(void*)&pwplib.set.audev,
    "volume", OPT_INT,(void*)32,(void*)&pwplib.setup[SETUP_VOLUME],
 
+#if (defined(DRIVE_SDL))
+   "fs",     OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_FULLSCREEN],
+   "xres",   OPT_INT,(void*)640,(void*)&pwplib.setup[SETUP_XRES],
+   "yres",   OPT_INT,(void*)480,(void*)&pwplib.setup[SETUP_YRES],
+#endif
+
    NULL,0,NULL,NULL
 };
 
@@ -305,7 +311,18 @@
 
          "  bps n     non-rt: fix to n bits per second, no delay\n"
          "  fps n     non-rt: fix to n frames per second, no delay\n"
-         "\n",pwplib.argv[0]);
+         
+         "\n"
+
+#if (defined(DRIVE_SDL))
+         "  fs        full screen mode (SDL)\n"
+         "  xres x    graphical x resolution (640)\n"
+         "  yres x    graphical y resolution (480)\n"
+
+         "\n"
+#endif
+         ,
+         pwplib.argv[0]);
 }
 
 void pwplib_getopts()