From 8c056b9185d8ab0d1b49a4432e0c819444f4cdf3 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 31 May 2005 12:31:11 +0000 Subject: [PATCH] Add Centscreen extended modes support --- README.MiNT | 7 ++- src/video/xbios/SDL_xbios.c | 19 +++++++-- src/video/xbios/SDL_xbios.h | 3 ++ src/video/xbios/SDL_xbios_centscreen.c | 59 +++++++++++++++++++++++--- src/video/xbios/SDL_xbios_centscreen.h | 4 +- src/video/xbios/SDL_xbios_sb3.c | 3 +- 6 files changed, 79 insertions(+), 16 deletions(-) diff --git a/README.MiNT b/README.MiNT index 65fac3920..6b04099cb 100644 --- a/README.MiNT +++ b/README.MiNT @@ -141,8 +141,8 @@ OpenGL: parameters, in the standard one, it has 6 double parameters. If you want to compile testdyngl, or any other SDL program that loads its OpenGL library, you must change the glOrtho() prototype used in this program. In - osmesa.ldg, you can retrieve a glOrtho() with double parameters, by searching - for the function "glOrtho6d". + osmesa.ldg, you can retrieve a glOrtho() with double parameters, by + searching for the function "glOrtho6d". Xbios video: Video chip is detected using the _VDO cookie. @@ -156,8 +156,7 @@ Xbios video: 320x480x8 and 320x240x8 (software double-lined mode). Falcon: All modes supported by the current monitor (RVB or VGA). - BlowUp extended modes, ScreenBlaster 3 current mode, Centscreen current - mode. + BlowUp and Centscreen extended modes, ScreenBlaster 3 current mode. Clones and any machine with monochrome monitor: Not supported. diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index e49181a36..337f4577e 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -283,6 +283,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) /* and save current screen status (palette, screen address, video mode) */ XBIOS_nummodes = 0; XBIOS_modelist = NULL; + XBIOS_centscreen = SDL_FALSE; switch (XBIOS_cvdo >>16) { case VDO_ST: @@ -411,14 +412,16 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) current_mode++; } - /* Initialize BlowUp or SB3 stuff if present */ + /* Initialize BlowUp/SB3/Centscreen stuff if present */ if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) { SDL_XBIOS_BlowupInit(this, (blow_cookie_t *)cookie_blow); } else if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) { SDL_XBIOS_SB3Init(this, (scpn_cookie_t *)cookie_scpn); } else if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) { - SDL_XBIOS_CentscreenInit(this); + XBIOS_oldvmode = SDL_XBIOS_CentscreenInit(this); + XBIOS_centscreen = SDL_TRUE; } + break; } @@ -680,7 +683,11 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, break; case VDO_F30: #ifndef DEBUG_VIDEO_XBIOS - Vsetmode(new_video_mode->number); + if (XBIOS_centscreen) { + SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth); + } else { + Vsetmode(new_video_mode->number); + } #endif break; } @@ -892,7 +899,11 @@ static void XBIOS_VideoQuit(_THIS) break; case VDO_F30: Setscreen(-1, XBIOS_oldvbase, -1); - Vsetmode(XBIOS_oldvmode); + if (XBIOS_centscreen) { + SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode); + } else { + Vsetmode(XBIOS_oldvmode); + } if (XBIOS_oldnumcol) { VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette); } diff --git a/src/video/xbios/SDL_xbios.h b/src/video/xbios/SDL_xbios.h index c1b1cc160..c1660a12a 100644 --- a/src/video/xbios/SDL_xbios.h +++ b/src/video/xbios/SDL_xbios.h @@ -70,6 +70,8 @@ struct SDL_PrivateVideoData { int pitch; /* Destination line width for C2P */ int width, height; /* Screen size for centered C2P */ + SDL_bool centscreen; /* Centscreen extension present ? */ + SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES+1]; xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES+1]; }; @@ -123,6 +125,7 @@ enum { #define XBIOS_pitch (this->hidden->pitch) #define XBIOS_width (this->hidden->width) #define XBIOS_height (this->hidden->height) +#define XBIOS_centscreen (this->hidden->centscreen) /*--- Functions prototypes ---*/ diff --git a/src/video/xbios/SDL_xbios_centscreen.c b/src/video/xbios/SDL_xbios_centscreen.c index db4790325..248fcf0e0 100644 --- a/src/video/xbios/SDL_xbios_centscreen.c +++ b/src/video/xbios/SDL_xbios_centscreen.c @@ -27,15 +27,18 @@ */ #include +#include #include #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 @@ void SDL_XBIOS_CentscreenInit(_THIS) 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); } diff --git a/src/video/xbios/SDL_xbios_centscreen.h b/src/video/xbios/SDL_xbios_centscreen.h index 9011e6aff..45871edf3 100644 --- a/src/video/xbios/SDL_xbios_centscreen.h +++ b/src/video/xbios/SDL_xbios_centscreen.h @@ -110,6 +110,8 @@ typedef struct { /*--- Functions prototypes ---*/ -void SDL_XBIOS_CentscreenInit(_THIS); +int SDL_XBIOS_CentscreenInit(_THIS); +void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes); +void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle); #endif /* _SDL_xbios_centscreen_h */ diff --git a/src/video/xbios/SDL_xbios_sb3.c b/src/video/xbios/SDL_xbios_sb3.c index a7c62ae31..25a4248a3 100644 --- a/src/video/xbios/SDL_xbios_sb3.c +++ b/src/video/xbios/SDL_xbios_sb3.c @@ -28,6 +28,8 @@ /*--- Includes ---*/ +#include + #include "SDL_xbios.h" #include "SDL_xbios_sb3.h" @@ -63,7 +65,6 @@ int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn) void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t *cookie_scpn) { - xbiosmode_t *current_mode; scpn_screeninfo_t *scrinfo; /* SB3 prevent changing video modes, we can only use current one */