Add Centscreen extended modes support
authorPatrice Mandin <patmandin@gmail.com>
Tue, 31 May 2005 12:31:11 +0000
changeset 1064fba6b67b4d60
parent 1063 0fb50bfaea7f
child 1065 5d9947da7510
Add Centscreen extended modes support
README.MiNT
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios.h
src/video/xbios/SDL_xbios_centscreen.c
src/video/xbios/SDL_xbios_centscreen.h
src/video/xbios/SDL_xbios_sb3.c
     1.1 --- a/README.MiNT	Fri May 20 20:37:28 2005 +0000
     1.2 +++ b/README.MiNT	Tue May 31 12:31:11 2005 +0000
     1.3 @@ -141,8 +141,8 @@
     1.4  	parameters, in the standard one, it has 6 double parameters. If you want
     1.5  	to compile testdyngl, or any other SDL program that loads its OpenGL
     1.6  	library, you must change the glOrtho() prototype used in this program. In
     1.7 -	osmesa.ldg, you can retrieve a glOrtho() with double parameters, by searching
     1.8 -	for the function "glOrtho6d".
     1.9 +	osmesa.ldg, you can retrieve a glOrtho() with double parameters, by
    1.10 +	searching for the function "glOrtho6d".
    1.11  
    1.12  Xbios video:
    1.13  	Video chip is detected using the _VDO cookie.
    1.14 @@ -156,8 +156,7 @@
    1.15  		320x480x8 and 320x240x8 (software double-lined mode).
    1.16  	Falcon:
    1.17  		All modes supported by the current monitor (RVB or VGA).
    1.18 -		BlowUp extended modes, ScreenBlaster 3 current mode, Centscreen current
    1.19 -		mode.
    1.20 +		BlowUp and Centscreen extended modes, ScreenBlaster 3 current mode.
    1.21  	Clones and any machine with monochrome monitor:
    1.22  		Not supported.
    1.23  
     2.1 --- a/src/video/xbios/SDL_xbios.c	Fri May 20 20:37:28 2005 +0000
     2.2 +++ b/src/video/xbios/SDL_xbios.c	Tue May 31 12:31:11 2005 +0000
     2.3 @@ -283,6 +283,7 @@
     2.4  	/* and save current screen status (palette, screen address, video mode) */
     2.5  	XBIOS_nummodes = 0;
     2.6  	XBIOS_modelist = NULL;
     2.7 +	XBIOS_centscreen = SDL_FALSE;
     2.8  
     2.9  	switch (XBIOS_cvdo >>16) {
    2.10  		case VDO_ST:
    2.11 @@ -411,14 +412,16 @@
    2.12  				current_mode++;
    2.13  			}
    2.14  
    2.15 -			/* Initialize BlowUp or SB3 stuff if present */
    2.16 +			/* Initialize BlowUp/SB3/Centscreen stuff if present */
    2.17  			if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) {
    2.18  				SDL_XBIOS_BlowupInit(this, (blow_cookie_t *)cookie_blow);
    2.19  			} else if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
    2.20  				SDL_XBIOS_SB3Init(this, (scpn_cookie_t *)cookie_scpn);
    2.21  			} else if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) {
    2.22 -				SDL_XBIOS_CentscreenInit(this);
    2.23 +				XBIOS_oldvmode = SDL_XBIOS_CentscreenInit(this);
    2.24 +				XBIOS_centscreen = SDL_TRUE;
    2.25  			}
    2.26 +
    2.27  			break;
    2.28  	}
    2.29  
    2.30 @@ -680,7 +683,11 @@
    2.31  			break;
    2.32  		case VDO_F30:
    2.33  #ifndef DEBUG_VIDEO_XBIOS
    2.34 -			Vsetmode(new_video_mode->number);
    2.35 +			if (XBIOS_centscreen) {
    2.36 +				SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth);
    2.37 +			} else {
    2.38 +				Vsetmode(new_video_mode->number);
    2.39 +			}
    2.40  #endif
    2.41  			break;
    2.42  	}
    2.43 @@ -892,7 +899,11 @@
    2.44  			break;
    2.45  		case VDO_F30:
    2.46  			Setscreen(-1, XBIOS_oldvbase, -1);
    2.47 -			Vsetmode(XBIOS_oldvmode);
    2.48 +			if (XBIOS_centscreen) {
    2.49 +				SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode);
    2.50 +			} else {
    2.51 +				Vsetmode(XBIOS_oldvmode);
    2.52 +			}
    2.53  			if (XBIOS_oldnumcol) {
    2.54  				VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
    2.55  			}
     3.1 --- a/src/video/xbios/SDL_xbios.h	Fri May 20 20:37:28 2005 +0000
     3.2 +++ b/src/video/xbios/SDL_xbios.h	Tue May 31 12:31:11 2005 +0000
     3.3 @@ -70,6 +70,8 @@
     3.4  	int pitch;				/* Destination line width for C2P */
     3.5  	int width, height;		/* Screen size for centered C2P */
     3.6  
     3.7 +	SDL_bool centscreen;	/* Centscreen extension present ? */
     3.8 +
     3.9  	SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES+1];
    3.10  	xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES+1];
    3.11  };
    3.12 @@ -123,6 +125,7 @@
    3.13  #define XBIOS_pitch			(this->hidden->pitch)
    3.14  #define XBIOS_width			(this->hidden->width)
    3.15  #define XBIOS_height		(this->hidden->height)
    3.16 +#define XBIOS_centscreen	(this->hidden->centscreen)
    3.17  
    3.18  /*--- Functions prototypes ---*/
    3.19  
     4.1 --- a/src/video/xbios/SDL_xbios_centscreen.c	Fri May 20 20:37:28 2005 +0000
     4.2 +++ b/src/video/xbios/SDL_xbios_centscreen.c	Tue May 31 12:31:11 2005 +0000
     4.3 @@ -27,15 +27,18 @@
     4.4  */
     4.5  
     4.6  #include <stdlib.h>
     4.7 +#include <string.h>
     4.8  
     4.9  #include <mint/falcon.h>
    4.10  
    4.11  #include "SDL_xbios.h"
    4.12  #include "SDL_xbios_centscreen.h"
    4.13  
    4.14 -void SDL_XBIOS_CentscreenInit(_THIS)
    4.15 +int SDL_XBIOS_CentscreenInit(_THIS)
    4.16  {
    4.17 -	centscreen_mode_t	curmode;
    4.18 +	centscreen_mode_t	curmode, listedmode;
    4.19 +	unsigned long result;
    4.20 +	int cur_handle;	/* Current Centscreen mode handle */
    4.21  
    4.22  	/* Reset current mode list */
    4.23  	if (XBIOS_modelist) {
    4.24 @@ -44,10 +47,54 @@
    4.25  		XBIOS_modelist = NULL;
    4.26  	}
    4.27  
    4.28 -	/* Add current active mode */
    4.29 +	/* Add Centscreen modes */
    4.30  	Vread(&curmode);
    4.31 +	cur_handle = curmode.handle;
    4.32 +	curmode.mode = curmode.physx = curmode.physy = curmode.plan =
    4.33 +		curmode.logx = curmode.logy = -1;
    4.34  
    4.35 -	SDL_XBIOS_AddMode(this, -1, curmode.physx, curmode.physy, curmode.plan,
    4.36 -		SDL_FALSE
    4.37 -	);
    4.38 +	result = Vfirst(&curmode, &listedmode);
    4.39 +	if (result==0) {
    4.40 +		while (result==0) {
    4.41 +			/* Don't add modes with virtual screen */
    4.42 +			if ((listedmode.mode & CSCREEN_VIRTUAL)==0) {
    4.43 +				/* Don't add modes with bpp<8 */
    4.44 +				if (listedmode.plan>=8) {
    4.45 +					SDL_XBIOS_AddMode(this, listedmode.mode, listedmode.physx,
    4.46 +						listedmode.physy, listedmode.plan, SDL_FALSE
    4.47 +					);
    4.48 +				}
    4.49 +			}
    4.50 +			memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
    4.51 +			curmode.mode = curmode.physx = curmode.physy = curmode.plan =
    4.52 +				curmode.logx = curmode.logy = -1;
    4.53 +			result = Vnext(&curmode, &listedmode);
    4.54 +		}		
    4.55 +	} else {
    4.56 +		fprintf(stderr, "No suitable Centscreen modes\n");
    4.57 +	}
    4.58 +
    4.59 +	return cur_handle;
    4.60  }
    4.61 +
    4.62 +void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
    4.63 +{
    4.64 +	centscreen_mode_t	newmode, curmode;
    4.65 +	
    4.66 +	newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
    4.67 +	newmode.physx = width;
    4.68 +	newmode.physy = height;
    4.69 +	newmode.plan = planes;
    4.70 +	Vwrite(0, &newmode, &curmode);
    4.71 +}
    4.72 +
    4.73 +void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
    4.74 +{
    4.75 +	centscreen_mode_t	newmode, curmode;
    4.76 +
    4.77 +	/* Restore old video mode */
    4.78 +	newmode.handle = prev_handle;
    4.79 +	newmode.mode = newmode.physx = newmode.physy = newmode.plan =
    4.80 +		newmode.logx = newmode.logy = -1;
    4.81 +	Vwrite(0, &newmode, &curmode);
    4.82 +}
     5.1 --- a/src/video/xbios/SDL_xbios_centscreen.h	Fri May 20 20:37:28 2005 +0000
     5.2 +++ b/src/video/xbios/SDL_xbios_centscreen.h	Tue May 31 12:31:11 2005 +0000
     5.3 @@ -110,6 +110,8 @@
     5.4  
     5.5  /*--- Functions prototypes ---*/
     5.6  
     5.7 -void SDL_XBIOS_CentscreenInit(_THIS);
     5.8 +int SDL_XBIOS_CentscreenInit(_THIS);
     5.9 +void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes);
    5.10 +void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle);
    5.11  
    5.12  #endif /* _SDL_xbios_centscreen_h */
     6.1 --- a/src/video/xbios/SDL_xbios_sb3.c	Fri May 20 20:37:28 2005 +0000
     6.2 +++ b/src/video/xbios/SDL_xbios_sb3.c	Tue May 31 12:31:11 2005 +0000
     6.3 @@ -28,6 +28,8 @@
     6.4  
     6.5  /*--- Includes ---*/
     6.6  
     6.7 +#include <stdlib.h>
     6.8 +
     6.9  #include "SDL_xbios.h"
    6.10  #include "SDL_xbios_sb3.h"
    6.11  
    6.12 @@ -63,7 +65,6 @@
    6.13  
    6.14  void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t *cookie_scpn)
    6.15  {
    6.16 -	xbiosmode_t *current_mode;
    6.17  	scpn_screeninfo_t *scrinfo;
    6.18  
    6.19  	/* SB3 prevent changing video modes, we can only use current one */