src/video/xbios/SDL_xbios_centscreen.c
changeset 1064 fba6b67b4d60
parent 1061 5023cde12cbd
child 1105 1c9988e47824
     1.1 --- a/src/video/xbios/SDL_xbios_centscreen.c	Fri May 20 20:37:28 2005 +0000
     1.2 +++ b/src/video/xbios/SDL_xbios_centscreen.c	Tue May 31 12:31:11 2005 +0000
     1.3 @@ -27,15 +27,18 @@
     1.4  */
     1.5  
     1.6  #include <stdlib.h>
     1.7 +#include <string.h>
     1.8  
     1.9  #include <mint/falcon.h>
    1.10  
    1.11  #include "SDL_xbios.h"
    1.12  #include "SDL_xbios_centscreen.h"
    1.13  
    1.14 -void SDL_XBIOS_CentscreenInit(_THIS)
    1.15 +int SDL_XBIOS_CentscreenInit(_THIS)
    1.16  {
    1.17 -	centscreen_mode_t	curmode;
    1.18 +	centscreen_mode_t	curmode, listedmode;
    1.19 +	unsigned long result;
    1.20 +	int cur_handle;	/* Current Centscreen mode handle */
    1.21  
    1.22  	/* Reset current mode list */
    1.23  	if (XBIOS_modelist) {
    1.24 @@ -44,10 +47,54 @@
    1.25  		XBIOS_modelist = NULL;
    1.26  	}
    1.27  
    1.28 -	/* Add current active mode */
    1.29 +	/* Add Centscreen modes */
    1.30  	Vread(&curmode);
    1.31 +	cur_handle = curmode.handle;
    1.32 +	curmode.mode = curmode.physx = curmode.physy = curmode.plan =
    1.33 +		curmode.logx = curmode.logy = -1;
    1.34  
    1.35 -	SDL_XBIOS_AddMode(this, -1, curmode.physx, curmode.physy, curmode.plan,
    1.36 -		SDL_FALSE
    1.37 -	);
    1.38 +	result = Vfirst(&curmode, &listedmode);
    1.39 +	if (result==0) {
    1.40 +		while (result==0) {
    1.41 +			/* Don't add modes with virtual screen */
    1.42 +			if ((listedmode.mode & CSCREEN_VIRTUAL)==0) {
    1.43 +				/* Don't add modes with bpp<8 */
    1.44 +				if (listedmode.plan>=8) {
    1.45 +					SDL_XBIOS_AddMode(this, listedmode.mode, listedmode.physx,
    1.46 +						listedmode.physy, listedmode.plan, SDL_FALSE
    1.47 +					);
    1.48 +				}
    1.49 +			}
    1.50 +			memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
    1.51 +			curmode.mode = curmode.physx = curmode.physy = curmode.plan =
    1.52 +				curmode.logx = curmode.logy = -1;
    1.53 +			result = Vnext(&curmode, &listedmode);
    1.54 +		}		
    1.55 +	} else {
    1.56 +		fprintf(stderr, "No suitable Centscreen modes\n");
    1.57 +	}
    1.58 +
    1.59 +	return cur_handle;
    1.60  }
    1.61 +
    1.62 +void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
    1.63 +{
    1.64 +	centscreen_mode_t	newmode, curmode;
    1.65 +	
    1.66 +	newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
    1.67 +	newmode.physx = width;
    1.68 +	newmode.physy = height;
    1.69 +	newmode.plan = planes;
    1.70 +	Vwrite(0, &newmode, &curmode);
    1.71 +}
    1.72 +
    1.73 +void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
    1.74 +{
    1.75 +	centscreen_mode_t	newmode, curmode;
    1.76 +
    1.77 +	/* Restore old video mode */
    1.78 +	newmode.handle = prev_handle;
    1.79 +	newmode.mode = newmode.physx = newmode.physy = newmode.plan =
    1.80 +		newmode.logx = newmode.logy = -1;
    1.81 +	Vwrite(0, &newmode, &curmode);
    1.82 +}