diff src/video/xbios/SDL_xbios_centscreen.c @ 1064:fba6b67b4d60

Add Centscreen extended modes support
author Patrice Mandin <patmandin@gmail.com>
date Tue, 31 May 2005 12:31:11 +0000
parents 5023cde12cbd
children 1c9988e47824
line wrap: on
line diff
--- a/src/video/xbios/SDL_xbios_centscreen.c	Fri May 20 20:37:28 2005 +0000
+++ b/src/video/xbios/SDL_xbios_centscreen.c	Tue May 31 12:31:11 2005 +0000
@@ -27,15 +27,18 @@
 */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include <mint/falcon.h>
 
 #include "SDL_xbios.h"
 #include "SDL_xbios_centscreen.h"
 
-void SDL_XBIOS_CentscreenInit(_THIS)
+int SDL_XBIOS_CentscreenInit(_THIS)
 {
-	centscreen_mode_t	curmode;
+	centscreen_mode_t	curmode, listedmode;
+	unsigned long result;
+	int cur_handle;	/* Current Centscreen mode handle */
 
 	/* Reset current mode list */
 	if (XBIOS_modelist) {
@@ -44,10 +47,54 @@
 		XBIOS_modelist = NULL;
 	}
 
-	/* Add current active mode */
+	/* Add Centscreen modes */
 	Vread(&curmode);
+	cur_handle = curmode.handle;
+	curmode.mode = curmode.physx = curmode.physy = curmode.plan =
+		curmode.logx = curmode.logy = -1;
 
-	SDL_XBIOS_AddMode(this, -1, curmode.physx, curmode.physy, curmode.plan,
-		SDL_FALSE
-	);
+	result = Vfirst(&curmode, &listedmode);
+	if (result==0) {
+		while (result==0) {
+			/* Don't add modes with virtual screen */
+			if ((listedmode.mode & CSCREEN_VIRTUAL)==0) {
+				/* Don't add modes with bpp<8 */
+				if (listedmode.plan>=8) {
+					SDL_XBIOS_AddMode(this, listedmode.mode, listedmode.physx,
+						listedmode.physy, listedmode.plan, SDL_FALSE
+					);
+				}
+			}
+			memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
+			curmode.mode = curmode.physx = curmode.physy = curmode.plan =
+				curmode.logx = curmode.logy = -1;
+			result = Vnext(&curmode, &listedmode);
+		}		
+	} else {
+		fprintf(stderr, "No suitable Centscreen modes\n");
+	}
+
+	return cur_handle;
 }
+
+void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
+{
+	centscreen_mode_t	newmode, curmode;
+	
+	newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
+	newmode.physx = width;
+	newmode.physy = height;
+	newmode.plan = planes;
+	Vwrite(0, &newmode, &curmode);
+}
+
+void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
+{
+	centscreen_mode_t	newmode, curmode;
+
+	/* Restore old video mode */
+	newmode.handle = prev_handle;
+	newmode.mode = newmode.physx = newmode.physy = newmode.plan =
+		newmode.logx = newmode.logy = -1;
+	Vwrite(0, &newmode, &curmode);
+}