Commit ccc4e650 authored by Patrice Mandin's avatar Patrice Mandin

Preliminary work to support the Milan video bios, that will gives access to 24...

Preliminary work to support the Milan video bios, that will gives access to 24 or 32 bpp modes. I used the svga driver as model to dynamically build video modes list.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403820
parent 1aeda60e
...@@ -94,6 +94,45 @@ static void XBIOS_GL_SwapBuffers(_THIS); ...@@ -94,6 +94,45 @@ static void XBIOS_GL_SwapBuffers(_THIS);
static unsigned short TT_palette[256]; static unsigned short TT_palette[256];
static unsigned long F30_palette[256]; static unsigned long F30_palette[256];
/* Default list of video modes */
static const xbiosmode_t stmodes[1]={
{ST_LOW>>8,320,200,4,SDL_FALSE}
};
static const xbiosmode_t ttmodes[2]={
{TT_LOW,320,480,8,SDL_FALSE},
{TT_LOW,320,240,8,SDL_TRUE} /* Software double-lined mode */
};
static const xbiosmode_t falconrgbmodes[16]={
{BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE},
{BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE},
{BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE},
{BPS16|COL80,640,200,16,SDL_FALSE},
{BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE},
{BPS16|OVERSCAN,384,240,16,SDL_FALSE},
{BPS16|VERTFLAG,320,400,16,SDL_FALSE},
{BPS16,320,200,16,SDL_FALSE},
{BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE},
{BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE},
{BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE},
{BPS8|COL80,640,200,8,SDL_FALSE},
{BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE},
{BPS8|OVERSCAN,384,240,8,SDL_FALSE},
{BPS8|VERTFLAG,320,400,8,SDL_FALSE},
{BPS8,320,200,8,SDL_FALSE}
};
static const xbiosmode_t falconvgamodes[6]={
{BPS16,320,480,16,SDL_FALSE},
{BPS16|VERTFLAG,320,240,16,SDL_FALSE},
{BPS8|COL80,640,480,8,SDL_FALSE},
{BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE},
{BPS8,320,480,8,SDL_FALSE},
{BPS8|VERTFLAG,320,240,8,SDL_FALSE}
};
/* Xbios driver bootstrap functions */ /* Xbios driver bootstrap functions */
static int XBIOS_Available(void) static int XBIOS_Available(void)
...@@ -216,55 +255,105 @@ VideoBootStrap XBIOS_bootstrap = { ...@@ -216,55 +255,105 @@ VideoBootStrap XBIOS_bootstrap = {
XBIOS_Available, XBIOS_CreateDevice XBIOS_Available, XBIOS_CreateDevice
}; };
void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, void SDL_XBIOS_AddMode(_THIS, int actually_add, const xbiosmode_t *modeinfo)
Uint16 depth, SDL_bool flags)
{ {
int i, curpos; int i = 0;
xbiosmode_t *current_mode;
/* Check if mode already exists */ switch(modeinfo->depth) {
if (XBIOS_modelist) { case 15:
current_mode = XBIOS_modelist; case 16:
for (i=0;i<XBIOS_nummodes; i++, current_mode++) { i = 1;
if (current_mode->width != width) break;
continue; case 24:
if (current_mode->height != height) i = 2;
continue; break;
if (current_mode->depth != depth) case 32:
continue; i = 3;
return; break;
}
} }
++XBIOS_nummodes; if ( actually_add ) {
XBIOS_modelist = (xbiosmode_t *) SDL_realloc(XBIOS_modelist, XBIOS_nummodes * sizeof(xbiosmode_t)); SDL_Rect saved_rect[2];
xbiosmode_t saved_mode[2];
/* Keep the list sorted: bpp, width, height */ int b, j;
curpos=0;
for(i=0; i<XBIOS_nummodes-1; i++) { /* Add the mode, sorted largest to smallest */
if (XBIOS_modelist[i].depth <= depth) { b = 0;
if (XBIOS_modelist[i].width < width) { j = 0;
break; while ( (SDL_modelist[i][j]->w > modeinfo->width) ||
} else if (XBIOS_modelist[i].width == width) { (SDL_modelist[i][j]->h > modeinfo->height) ) {
if (XBIOS_modelist[i].height <= height) { ++j;
break;
} }
/* Skip modes that are already in our list */
if ( (SDL_modelist[i][j]->w == modeinfo->width) &&
(SDL_modelist[i][j]->h == modeinfo->height) ) {
return;
} }
/* Insert the new mode */
saved_rect[b] = *SDL_modelist[i][j];
SDL_memcpy(&saved_mode[b], SDL_xbiosmode[i][j], sizeof(xbiosmode_t));
SDL_modelist[i][j]->w = modeinfo->width;
SDL_modelist[i][j]->h = modeinfo->height;
SDL_memcpy(SDL_xbiosmode[i][j], modeinfo, sizeof(xbiosmode_t));
/* Everybody scoot down! */
if ( saved_rect[b].w && saved_rect[b].h ) {
for ( ++j; SDL_modelist[i][j]->w; ++j ) {
saved_rect[!b] = *SDL_modelist[i][j];
memcpy(&saved_mode[!b], SDL_xbiosmode[i][j], sizeof(xbiosmode_t));
*SDL_modelist[i][j] = saved_rect[b];
SDL_memcpy(SDL_xbiosmode[i][j], &saved_mode[b], sizeof(xbiosmode_t));
b = !b;
}
*SDL_modelist[i][j] = saved_rect[b];
SDL_memcpy(SDL_xbiosmode[i][j], &saved_mode[b], sizeof(xbiosmode_t));
} }
curpos++; } else {
++SDL_nummodes[i];
} }
}
static void XBIOS_ListSTModes(_THIS, int actually_add)
{
SDL_XBIOS_AddMode(this, actually_add, &stmodes[0]);
}
/* Push remaining modes further */ static void XBIOS_ListTTModes(_THIS, int actually_add)
for(i=XBIOS_nummodes-1; i>curpos; i--) { {
SDL_memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i-1], sizeof(xbiosmode_t)); int i;
for (i=0; i<2; i++) {
SDL_XBIOS_AddMode(this, actually_add, &ttmodes[i]);
} }
}
static void XBIOS_ListFalconRgbModes(_THIS, int actually_add)
{
int i;
for (i=0; i<16; i++) {
xbiosmode_t modeinfo;
XBIOS_modelist[curpos].number = modecode; SDL_memcpy(&modeinfo, &falconrgbmodes[i], sizeof(xbiosmode_t));
XBIOS_modelist[curpos].width = width; modeinfo.number &= ~(VGA|PAL);
XBIOS_modelist[curpos].height = height; modeinfo.number |= XBIOS_oldvmode & (VGA|PAL);
XBIOS_modelist[curpos].depth = depth;
XBIOS_modelist[curpos].doubleline = flags; SDL_XBIOS_AddMode(this, actually_add, &modeinfo);
}
}
static void XBIOS_ListFalconVgaModes(_THIS, int actually_add)
{
int i;
for (i=0; i<6; i++) {
xbiosmode_t modeinfo;
SDL_memcpy(&modeinfo, &falconvgamodes[i], sizeof(xbiosmode_t));
modeinfo.number &= ~(VGA|PAL);
modeinfo.number |= XBIOS_oldvmode & (VGA|PAL);
SDL_XBIOS_AddMode(this, actually_add, &modeinfo);
}
} }
static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
...@@ -274,7 +363,11 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -274,7 +363,11 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
unsigned long cookie_blow, cookie_scpn, cookie_cnts; unsigned long cookie_blow, cookie_scpn, cookie_cnts;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
memset (SDL_modelist, 0, sizeof(SDL_modelist)); for ( i=0; i<NUM_MODELISTS; ++i ) {
SDL_nummodes[i] = 0;
SDL_modelist[i] = NULL;
SDL_xbiosmode[i] = NULL;
}
/* Cookie _VDO present ? if not, assume ST machine */ /* Cookie _VDO present ? if not, assume ST machine */
if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) { if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
...@@ -290,18 +383,22 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -290,18 +383,22 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Initialize video mode list */ /* Initialize video mode list */
/* and save current screen status (palette, screen address, video mode) */ /* and save current screen status (palette, screen address, video mode) */
XBIOS_nummodes = 0;
XBIOS_modelist = NULL;
XBIOS_centscreen = SDL_FALSE; XBIOS_centscreen = SDL_FALSE;
/* Determine the current screen size */
this->info.current_w = 0;
this->info.current_h = 0;
/* Determine the screen depth (use default 8-bit depth) */
vformat->BitsPerPixel = 8;
/* First allocate room for needed video modes */
switch (XBIOS_cvdo >>16) { switch (XBIOS_cvdo >>16) {
case VDO_ST: case VDO_ST:
case VDO_STE: case VDO_STE:
{ {
short *oldpalette; short *oldpalette;
SDL_XBIOS_AddMode(this, ST_LOW>>8,320,200,4,SDL_FALSE);
XBIOS_oldvbase=Physbase(); XBIOS_oldvbase=Physbase();
XBIOS_oldvmode=Getrez(); XBIOS_oldvmode=Getrez();
switch(XBIOS_oldvmode << 8) { switch(XBIOS_oldvmode << 8) {
...@@ -314,9 +411,6 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -314,9 +411,6 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
case ST_HIGH: case ST_HIGH:
XBIOS_oldnumcol=2; XBIOS_oldnumcol=2;
break; break;
default:
XBIOS_oldnumcol=0;
break;
} }
oldpalette= (short *) XBIOS_oldpalette; oldpalette= (short *) XBIOS_oldpalette;
...@@ -324,15 +418,10 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -324,15 +418,10 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
*oldpalette++=Setcolor(i,-1); *oldpalette++=Setcolor(i,-1);
} }
vformat->BitsPerPixel = 8; XBIOS_ListSTModes(this, 0);
} }
break; break;
case VDO_TT: case VDO_TT:
SDL_XBIOS_AddMode(this, TT_LOW,320,480,8,SDL_FALSE);
/* Software double-lined mode */
SDL_XBIOS_AddMode(this, TT_LOW,320,240,8,SDL_TRUE);
XBIOS_oldvbase=Logbase(); XBIOS_oldvbase=Logbase();
XBIOS_oldvmode=EgetShift(); XBIOS_oldvmode=EgetShift();
...@@ -351,50 +440,14 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -351,50 +440,14 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
case TT_HIGH: case TT_HIGH:
XBIOS_oldnumcol=2; XBIOS_oldnumcol=2;
break; break;
default:
XBIOS_oldnumcol=0;
break;
} }
if (XBIOS_oldnumcol) { if (XBIOS_oldnumcol) {
EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette); EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
} }
vformat->BitsPerPixel = 8; XBIOS_ListTTModes(this, 0);
break; break;
case VDO_F30: case VDO_F30:
switch (VgetMonitor())
{
case MONITOR_MONO:
/* Not usable */
break;
case MONITOR_RGB:
case MONITOR_TV:
SDL_XBIOS_AddMode(this, BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|COL80,640,200,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|OVERSCAN,384,240,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|VERTFLAG,320,400,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16,320,200,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80,640,200,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|OVERSCAN,384,240,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|VERTFLAG,320,400,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8,320,200,8,SDL_FALSE);
break;
case MONITOR_VGA:
SDL_XBIOS_AddMode(this, BPS16,320,480,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS16|VERTFLAG,320,240,16,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80,640,480,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8,320,480,8,SDL_FALSE);
SDL_XBIOS_AddMode(this, BPS8|VERTFLAG,320,240,8,SDL_FALSE);
break;
}
XBIOS_oldvbase=Logbase(); XBIOS_oldvbase=Logbase();
XBIOS_oldvmode=VsetMode(-1); XBIOS_oldvmode=VsetMode(-1);
...@@ -408,64 +461,98 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -408,64 +461,98 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
vformat->BitsPerPixel = 16; vformat->BitsPerPixel = 16;
/* Keep vga/rvb, and pal/ntsc bits */ /* ScreenBlaster 3 ? */
current_mode = XBIOS_modelist; if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
for (i=0;i<XBIOS_nummodes;i++) { SDL_XBIOS_ListSB3Modes(this, 0, (scpn_cookie_t *)cookie_scpn);
Uint16 newvmode; } else
/* Centscreen ? */
newvmode = current_mode->number; if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) {
newvmode &= ~(VGA|PAL); XBIOS_oldvmode = SDL_XBIOS_ListCentscreenModes(this, 0);
newvmode |= XBIOS_oldvmode & (VGA|PAL); XBIOS_centscreen = SDL_TRUE;
current_mode->number = newvmode; } else
/* Standard, with or without Blowup */
current_mode++; {
switch (VgetMonitor())
{
case MONITOR_RGB:
case MONITOR_TV:
XBIOS_ListFalconRgbModes(this, 0);
break;
case MONITOR_VGA:
XBIOS_ListFalconVgaModes(this, 0);
break;
} }
/* Initialize BlowUp/SB3/Centscreen stuff if present */
if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) { if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) {
SDL_XBIOS_BlowupInit(this, (blow_cookie_t *)cookie_blow); SDL_XBIOS_ListBlowupModes(this, 0, (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) {
XBIOS_oldvmode = SDL_XBIOS_CentscreenInit(this);
XBIOS_centscreen = SDL_TRUE;
} }
break; break;
} }
/* Determine the current screen size */ for ( i=0; i<NUM_MODELISTS; ++i ) {
if ( XBIOS_nummodes > 0 ) { int j;
/* FIXME: parse video mode list to search for current mode */
this->info.current_w = XBIOS_modelist[0].width; SDL_xbiosmode[i] = (xbiosmode_t **)SDL_malloc(SDL_nummodes[i]*sizeof(xbiosmode_t));
this->info.current_h = XBIOS_modelist[0].height; if ( SDL_xbiosmode[i] == NULL ) {
} SDL_OutOfMemory();
return(-1);
current_mode = XBIOS_modelist; }
j8 = j16 = 0; SDL_modelist[i] = (SDL_Rect **)
for (i=0; i<XBIOS_nummodes; i++, current_mode++) { SDL_malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
switch (current_mode->depth) { if ( SDL_modelist[i] == NULL ) {
case 4: SDL_OutOfMemory();
case 8: return(-1);
SDL_modelist[0][j8] = SDL_malloc(sizeof(SDL_Rect)); }
SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0; for ( j=0; j<SDL_nummodes[i]; ++j ) {
SDL_modelist[0][j8]->w = current_mode->width; SDL_modelist[i][j]=(SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
SDL_modelist[0][j8]->h = current_mode->height; if ( SDL_modelist[i][j] == NULL ) {
XBIOS_videomodes[0][j8]=current_mode; SDL_OutOfMemory();
j8++; return(-1);
}
SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect));
}
SDL_modelist[i][j] = NULL;
}
/* Now fill the mode list */
switch (XBIOS_cvdo >>16) {
case VDO_ST:
case VDO_STE:
XBIOS_ListSTModes(this, 1);
break; break;
case 16: case VDO_TT:
SDL_modelist[1][j16] = SDL_malloc(sizeof(SDL_Rect)); XBIOS_ListTTModes(this, 1);
SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0; break;
SDL_modelist[1][j16]->w = current_mode->width; case VDO_F30:
SDL_modelist[1][j16]->h = current_mode->height; /* ScreenBlaster 3 ? */
XBIOS_videomodes[1][j16]=current_mode; if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
j16++; SDL_XBIOS_ListSB3Modes(this, 1, (scpn_cookie_t *)cookie_scpn);
} else
/* Centscreen ? */
if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) {
XBIOS_oldvmode = SDL_XBIOS_ListCentscreenModes(this, 1);
XBIOS_centscreen = SDL_TRUE;
} else
/* Standard, with or without Blowup */
{
switch (VgetMonitor())
{
case MONITOR_RGB:
case MONITOR_TV:
XBIOS_ListFalconRgbModes(this, 1);
break; break;
case MONITOR_VGA:
XBIOS_ListFalconVgaModes(this, 1);
break;
}
if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) {
SDL_XBIOS_ListBlowupModes(this, 1, (blow_cookie_t *)cookie_blow);
} }
} }
SDL_modelist[0][j8] = NULL; break;
SDL_modelist[1][j16] = NULL; }
XBIOS_screens[0]=NULL; XBIOS_screens[0]=NULL;
XBIOS_screens[1]=NULL; XBIOS_screens[1]=NULL;
...@@ -493,13 +580,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -493,13 +580,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
{ {
/* 8 bits -> list 0 */ return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
/* 16 bits -> list 1 */
if ((format->BitsPerPixel != 8) && (format->BitsPerPixel !=16)) {
return NULL;
}
return(SDL_modelist[(format->BitsPerPixel)>>4]);
} }
static void XBIOS_FreeBuffers(_THIS) static void XBIOS_FreeBuffers(_THIS)
...@@ -531,17 +612,11 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -531,17 +612,11 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
/* Free current buffers */ /* Free current buffers */
XBIOS_FreeBuffers(this); XBIOS_FreeBuffers(this);
/* Limit bpp */ /* Try to set the requested linear video mode */
if (bpp>16) { bpp = (bpp+7)/8-1;
bpp = 16;
}
bpp >>= 4;
/* Search if the mode exists (width, height, bpp) */
for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) { for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) {
if ( (SDL_modelist[bpp][mode]->w == width) && if ( (SDL_modelist[bpp][mode]->w == width) &&
(SDL_modelist[bpp][mode]->h == height) ) { (SDL_modelist[bpp][mode]->h == height) ) {
break; break;
} }
} }
...@@ -549,11 +624,11 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -549,11 +624,11 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
SDL_SetError("Couldn't find requested mode in list"); SDL_SetError("Couldn't find requested mode in list");
return(NULL); return(NULL);
} }
new_video_mode = SDL_xbiosmode[bpp][mode];
modeflags = SDL_FULLSCREEN | SDL_PREALLOC; modeflags = SDL_FULLSCREEN | SDL_PREALLOC;
/* Allocate needed buffers: simple/double buffer and shadow surface */ /* Allocate needed buffers: simple/double buffer and shadow surface */
new_video_mode = XBIOS_videomodes[bpp][mode];
new_depth = new_video_mode->depth; new_depth = new_video_mode->depth;
if (new_depth == 4) { if (new_depth == 4) {
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4; SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4;
...@@ -655,28 +730,23 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -655,28 +730,23 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
current->flags = modeflags; current->flags = modeflags;
/* Now set the video mode */
#ifndef DEBUG_VIDEO_XBIOS #ifndef DEBUG_VIDEO_XBIOS
/* Now set the video mode */
Setscreen(-1,XBIOS_screens[0],-1); Setscreen(-1,XBIOS_screens[0],-1);
#endif
switch(XBIOS_cvdo >> 16) { switch(XBIOS_cvdo >> 16) {
case VDO_ST: case VDO_ST:
#ifndef DEBUG_VIDEO_XBIOS
Setscreen(-1,-1,new_video_mode->number); Setscreen(-1,-1,new_video_mode->number);
#endif
/* Reset palette */ /* Reset palette */
for (i=0;i<16;i++) { for (i=0;i<16;i++) {
TT_palette[i]= ((i>>1)<<8) | (((i*8)/17)<<4) | (i>>1); TT_palette[i]= ((i>>1)<<8) | (((i*8)/17)<<4) | (i>>1);
} }
#ifndef DEBUG_VIDEO_XBIOS
Setpalette(TT_palette); Setpalette(TT_palette);
#endif
break; break;
case VDO_STE: case VDO_STE:
#ifndef DEBUG_VIDEO_XBIOS
Setscreen(-1,-1,new_video_mode->number); Setscreen(-1,-1,new_video_mode->number);
#endif
/* Reset palette */ /* Reset palette */
for (i=0;i<16;i++) for (i=0;i<16;i++)
{ {
...@@ -685,23 +755,18 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -685,23 +755,18 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
c=((i&1)<<3)|((i>>1)&7); c=((i&1)<<3)|((i>>1)&7);
TT_palette[i]=(c<<8)|(c<<4)|c; TT_palette[i]=(c<<8)|(c<<4)|c;
} }
#ifndef DEBUG_VIDEO_XBIOS
Setpalette(TT_palette); Setpalette(TT_palette);
#endif
break; break;
case VDO_TT: case VDO_TT:
#ifndef DEBUG_VIDEO_XBIOS
EsetShift(new_video_mode->number); EsetShift(new_video_mode->number);
#endif
break; break;
case VDO_F30: case VDO_F30:
#ifndef DEBUG_VIDEO_XBIOS
if (XBIOS_centscreen) { if (XBIOS_centscreen) {
SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth); SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth);
} else { } else {
VsetMode(new_video_mode->number); VsetMode(new_video_mode->number);
} }
#endif
/* Set hardware palette to black in True Colour */ /* Set hardware palette to black in True Colour */
if (new_depth == 16) { if (new_depth == 16) {
SDL_memset(F30_palette, 0, sizeof(F30_palette)); SDL_memset(F30_palette, 0, sizeof(F30_palette));
...@@ -711,6 +776,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -711,6 +776,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
} }
Vsync(); Vsync();
#endif
this->UpdateRects = XBIOS_UpdateRects; this->UpdateRects = XBIOS_UpdateRects;
...@@ -780,8 +846,9 @@ static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects) ...@@ -780,8 +846,9 @@ static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
#ifndef DEBUG_VIDEO_XBIOS #ifndef DEBUG_VIDEO_XBIOS
Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
#endif
Vsync(); Vsync();
#endif
if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
XBIOS_fbnum ^= 1; XBIOS_fbnum ^= 1;
...@@ -818,8 +885,9 @@ static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface) ...@@ -818,8 +885,9 @@ static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
#ifndef DEBUG_VIDEO_XBIOS #ifndef DEBUG_VIDEO_XBIOS
Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
#endif
Vsync(); Vsync();
#endif
if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
XBIOS_fbnum ^= 1; XBIOS_fbnum ^= 1;
...@@ -833,6 +901,7 @@ static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface) ...@@ -833,6 +901,7 @@ static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{ {
#ifndef DEBUG_VIDEO_XBIOS
int i; int i;
int r,v,b; int r,v,b;
...@@ -858,9 +927,7 @@ static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors ...@@ -858,9 +927,7 @@ static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors
TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4); TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4);
} }
#ifndef DEBUG_VIDEO_XBIOS
EsetPalette(firstcolor,ncolors,TT_palette); EsetPalette(firstcolor,ncolors,TT_palette);
#endif
break; break;
case VDO_F30: case VDO_F30:
for(i = 0; i < ncolors; i++) for(i = 0; i < ncolors; i++)
...@@ -871,11 +938,10 @@ static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors ...@@ -871,11 +938,10 @@ static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors
F30_palette[i]=(r<<16)|(v<<8)|b; F30_palette[i]=(r<<16)|(v<<8)|b;
} }
#ifndef DEBUG_VIDEO_XBIOS
VsetRGB(firstcolor,ncolors,F30_palette); VsetRGB(firstcolor,ncolors,F30_palette);
#endif
break; break;
} }
#endif
return(1); return(1);
} }
...@@ -921,7 +987,6 @@ static void XBIOS_VideoQuit(_THIS) ...@@ -921,7 +987,6 @@ static void XBIOS_VideoQuit(_THIS)
Vsync(); Vsync();
#endif #endif
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
if (gl_active) { if (gl_active) {
SDL_AtariGL_Quit(this, SDL_TRUE); SDL_AtariGL_Quit(this, SDL_TRUE);
...@@ -935,21 +1000,21 @@ static void XBIOS_VideoQuit(_THIS) ...@@ -935,21 +1000,21 @@ static void XBIOS_VideoQuit(_THIS)
XBIOS_FreeBuffers(this); XBIOS_FreeBuffers(this);
/* Free mode list */ /* Free mode list */
for (j=0;j<NUM_MODELISTS;j++) { for ( i=0; i<NUM_MODELISTS; ++i ) {
for (i=0;i<SDL_NUMMODES;i++) { if ( SDL_modelist[i] != NULL ) {
if (SDL_modelist[j][i]!=NULL) { for ( j=0; SDL_modelist[i][j]; ++j )
SDL_free(SDL_modelist[j][i]); SDL_free(SDL_modelist[i][j]);
SDL_modelist[j][i]=NULL; SDL_free(SDL_modelist[i]);
} SDL_modelist[i] = NULL;
}
if ( SDL_xbiosmode[i] != NULL ) {
for ( j=0; SDL_xbiosmode[i][j]; ++j )
SDL_free(SDL_xbiosmode[i][j]);
SDL_free(SDL_xbiosmode[i]);
SDL_xbiosmode[i] = NULL;
} }
} }
if (XBIOS_modelist) {
SDL_free(XBIOS_modelist);
XBIOS_nummodes=0;
XBIOS_modelist=NULL;
}
this->screen->pixels = NULL; this->screen->pixels = NULL;
/* Restore screensavers */ /* Restore screensavers */
......
...@@ -30,13 +30,6 @@ ...@@ -30,13 +30,6 @@
/* Hidden "this" pointer for the video functions */ /* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this #define _THIS SDL_VideoDevice *this
/* TT video modes: 2
Falcon RVB: 16 (could be *2 by adding PAL/NTSC modes)
Falcon VGA: 6
ST low: 1
*/
#define SDL_NUMMODES 16
typedef struct typedef struct
{ {
Uint16 number; /* Video mode number */ Uint16 number; /* Video mode number */
...@@ -47,7 +40,7 @@ typedef struct ...@@ -47,7 +40,7 @@ typedef struct
} xbiosmode_t; } xbiosmode_t;
/* Private display data */ /* Private display data */
#define NUM_MODELISTS 2 /* 8 and 16 bits-per-pixel */ #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
struct SDL_PrivateVideoData { struct SDL_PrivateVideoData {
long cookie_vdo; long cookie_vdo;
...@@ -55,8 +48,6 @@ struct SDL_PrivateVideoData { ...@@ -55,8 +48,6 @@ struct SDL_PrivateVideoData {
void *old_video_base; /* Old pointer to screen buffer */ void *old_video_base; /* Old pointer to screen buffer */
void *old_palette; /* Old palette */ void *old_palette; /* Old palette */
Uint32 old_num_colors; /* Nb of colors in saved palette */ Uint32 old_num_colors; /* Nb of colors in saved palette */
int num_modes; /* Number of xbios video modes */
xbiosmode_t *mode_list; /* List of xbios video modes */
void *screens[2]; /* Pointers to aligned screen buffer */ void *screens[2]; /* Pointers to aligned screen buffer */
void *screensmem[2]; /* Pointers to screen buffer */ void *screensmem[2]; /* Pointers to screen buffer */
...@@ -68,8 +59,9 @@ struct SDL_PrivateVideoData { ...@@ -68,8 +59,9 @@ struct SDL_PrivateVideoData {
SDL_bool centscreen; /* Centscreen extension present ? */ SDL_bool centscreen; /* Centscreen extension present ? */
SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES+1]; int SDL_nummodes[NUM_MODELISTS];
xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES+1]; SDL_Rect **SDL_modelist[NUM_MODELISTS];
xbiosmode_t **SDL_xbiosmode[NUM_MODELISTS];
}; };
/* _VDO cookie values */ /* _VDO cookie values */
...@@ -102,19 +94,18 @@ enum { ...@@ -102,19 +94,18 @@ enum {
#endif #endif
/* Hidden structure -> variables names */ /* Hidden structure -> variables names */
#define SDL_nummodes (this->hidden->SDL_nummodes)
#define SDL_modelist (this->hidden->SDL_modelist) #define SDL_modelist (this->hidden->SDL_modelist)
#define SDL_xbiosmode (this->hidden->SDL_xbiosmode)
#define XBIOS_mutex (this->hidden->mutex) #define XBIOS_mutex (this->hidden->mutex)
#define XBIOS_cvdo (this->hidden->cookie_vdo) #define XBIOS_cvdo (this->hidden->cookie_vdo)
#define XBIOS_oldpalette (this->hidden->old_palette) #define XBIOS_oldpalette (this->hidden->old_palette)
#define XBIOS_oldnumcol (this->hidden->old_num_colors) #define XBIOS_oldnumcol (this->hidden->old_num_colors)
#define XBIOS_oldvbase (this->hidden->old_video_base) #define XBIOS_oldvbase (this->hidden->old_video_base)
#define XBIOS_oldvmode (this->hidden->old_video_mode) #define XBIOS_oldvmode (this->hidden->old_video_mode)
#define XBIOS_nummodes (this->hidden->num_modes)
#define XBIOS_modelist (this->hidden->mode_list)
#define XBIOS_screens (this->hidden->screens) #define XBIOS_screens (this->hidden->screens)
#define XBIOS_screensmem (this->hidden->screensmem) #define XBIOS_screensmem (this->hidden->screensmem)
#define XBIOS_shadowscreen (this->hidden->shadowscreen) #define XBIOS_shadowscreen (this->hidden->shadowscreen)
#define XBIOS_videomodes (this->hidden->videomodes)
#define XBIOS_doubleline (this->hidden->doubleline) #define XBIOS_doubleline (this->hidden->doubleline)
#define XBIOS_fbnum (this->hidden->frame_number) #define XBIOS_fbnum (this->hidden->frame_number)
#define XBIOS_pitch (this->hidden->pitch) #define XBIOS_pitch (this->hidden->pitch)
...@@ -124,7 +115,6 @@ enum { ...@@ -124,7 +115,6 @@ enum {
/*--- Functions prototypes ---*/ /*--- Functions prototypes ---*/
void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, void SDL_XBIOS_AddMode(_THIS, int actually_add, const xbiosmode_t *modeinfo);
Uint16 depth, SDL_bool flags);
#endif /* _SDL_xbios_h */ #endif /* _SDL_xbios_h */
...@@ -32,14 +32,21 @@ ...@@ -32,14 +32,21 @@
#include "SDL_xbios.h" #include "SDL_xbios.h"
#include "SDL_xbios_blowup.h" #include "SDL_xbios_blowup.h"
void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t *cookie_blow) void SDL_XBIOS_ListBlowupModes(_THIS, int actually_add, blow_cookie_t *cookie_blow)
{ {
int i, num_mode, bank; int i, j, num_mode, bank;
blow_mode_t *blow_mode; blow_mode_t *blow_mode;
xbiosmode_t modeinfo;
/* Add bit 15 for old modes */ if (actually_add) {
for (i=0;i<XBIOS_nummodes;i++) { /* Set bit 15 for old modes */
XBIOS_modelist[i].number |= 1<<15; for (i=0;i<NUM_MODELISTS;i++) {
if ( SDL_xbiosmode[i] != NULL ) {
for ( j=0; SDL_xbiosmode[i][j]; ++j ) {
SDL_xbiosmode[i][j]->number |= 1<<15;
}
}
}
} }
/* Add Blowup modes for 8 and 16 bpp */ /* Add Blowup modes for 8 and 16 bpp */
...@@ -57,13 +64,13 @@ void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t *cookie_blow) ...@@ -57,13 +64,13 @@ void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t *cookie_blow)
&& (cookie_blow->montype == MONITOR_TV))) && (cookie_blow->montype == MONITOR_TV)))
{ {
/* we can use this extended mode */ /* we can use this extended mode */
SDL_XBIOS_AddMode(this, modeinfo.number = (num_mode == 3 ? BPS8 : BPS16);
num_mode == 3 ? BPS8 : BPS16, modeinfo.width = blow_mode->width + 1;
blow_mode->width + 1, modeinfo.height = blow_mode->height + 1;
blow_mode->height + 1, modeinfo.depth = (num_mode == 3 ? 8 : 16);
num_mode == 3 ? 8 : 16, modeinfo.doubleline = SDL_FALSE;
SDL_FALSE
); SDL_XBIOS_AddMode(this, actually_add, &modeinfo);
} }
} }
} }
......
...@@ -81,6 +81,6 @@ typedef struct { ...@@ -81,6 +81,6 @@ typedef struct {
/*--- Functions prototypes ---*/ /*--- Functions prototypes ---*/
void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t *cookie_blow); void SDL_XBIOS_ListBlowupModes(_THIS, int actually_add, blow_cookie_t *cookie_blow);
#endif /* _SDL_xbios_blowup_h */ #endif /* _SDL_xbios_blowup_h */
...@@ -32,19 +32,12 @@ ...@@ -32,19 +32,12 @@
#include "SDL_xbios.h" #include "SDL_xbios.h"
#include "SDL_xbios_centscreen.h" #include "SDL_xbios_centscreen.h"
int SDL_XBIOS_CentscreenInit(_THIS) int SDL_XBIOS_ListCentscreenModes(_THIS, int actually_add)
{ {
centscreen_mode_t curmode, listedmode; centscreen_mode_t curmode, listedmode;
unsigned long result; unsigned long result;
int cur_handle; /* Current Centscreen mode handle */ int cur_handle; /* Current Centscreen mode handle */
/* Reset current mode list */
if (XBIOS_modelist) {
SDL_free(XBIOS_modelist);
XBIOS_nummodes = 0;
XBIOS_modelist = NULL;
}
/* Add Centscreen modes */ /* Add Centscreen modes */
Vread(&curmode); Vread(&curmode);
cur_handle = curmode.handle; cur_handle = curmode.handle;
...@@ -58,9 +51,15 @@ int SDL_XBIOS_CentscreenInit(_THIS) ...@@ -58,9 +51,15 @@ int SDL_XBIOS_CentscreenInit(_THIS)
if ((listedmode.mode & CSCREEN_VIRTUAL)==0) { if ((listedmode.mode & CSCREEN_VIRTUAL)==0) {
/* Don't add modes with bpp<8 */ /* Don't add modes with bpp<8 */
if (listedmode.plan>=8) { if (listedmode.plan>=8) {
SDL_XBIOS_AddMode(this, listedmode.mode, listedmode.physx, xbiosmode_t modeinfo;
listedmode.physy, listedmode.plan, SDL_FALSE
); modeinfo.number = listedmode.mode;
modeinfo.width = listedmode.physx;
modeinfo.height = listedmode.physy;
modeinfo.depth = listedmode.plan;
modeinfo.doubleline = SDL_FALSE;
SDL_XBIOS_AddMode(this, actually_add, &modeinfo);
} }
} }
SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t)); SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
......
...@@ -111,7 +111,7 @@ typedef struct { ...@@ -111,7 +111,7 @@ typedef struct {
/*--- Functions prototypes ---*/ /*--- Functions prototypes ---*/
int SDL_XBIOS_CentscreenInit(_THIS); int SDL_XBIOS_ListCentscreenModes(_THIS, int actually_add);
void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes); void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes);
void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle); void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle);
......
...@@ -63,24 +63,21 @@ int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn) ...@@ -63,24 +63,21 @@ int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn)
return 0; return 0;
} }
void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t *cookie_scpn) void SDL_XBIOS_ListSB3Modes(_THIS, int actually_add, scpn_cookie_t *cookie_scpn)
{ {
scpn_screeninfo_t *scrinfo; scpn_screeninfo_t *scrinfo;
xbiosmode_t modeinfo;
/* SB3 prevent changing video modes, we can only use current one */
if (XBIOS_modelist) {
SDL_free(XBIOS_modelist);
XBIOS_nummodes = 0;
XBIOS_modelist = NULL;
}
scrinfo = cookie_scpn->screen_info; scrinfo = cookie_scpn->screen_info;
if (actually_add) {
scrinfo->h_pos = scrinfo->v_pos = 0; scrinfo->h_pos = scrinfo->v_pos = 0;
}
modeinfo.number = -1;
modeinfo.width = scrinfo->virtual_width;
modeinfo.height = scrinfo->virtual_height;
modeinfo.depth = 1<<(SDL_XBIOS_scpn_planes_device[scrinfo->device]);
modeinfo.doubleline = SDL_FALSE;
SDL_XBIOS_AddMode(this, SDL_XBIOS_AddMode(this, actually_add, &modeinfo);
-1,
scrinfo->virtual_width, scrinfo->virtual_height,
1<<(SDL_XBIOS_scpn_planes_device[scrinfo->device]),
SDL_FALSE
);
} }
...@@ -77,6 +77,6 @@ typedef struct { ...@@ -77,6 +77,6 @@ typedef struct {
int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn); int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn);
void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t *cookie_scpn); void SDL_XBIOS_ListSB3Modes(_THIS, int actually_add, scpn_cookie_t *cookie_scpn);
#endif /* _SDL_xbios_sb3_h_ */ #endif /* _SDL_xbios_sb3_h_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment