xbios: preliminary video mode init
authorPatrice Mandin <patmandin@gmail.com>
Mon, 13 Nov 2006 19:59:28 +0000
changeset 20724b3f98a9a2c1
parent 2071 579abbb51f80
child 2073 790726541708
xbios: preliminary video mode init
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios.h
src/video/xbios/SDL_xbiosmodes.c
     1.1 --- a/src/video/xbios/SDL_xbios.c	Mon Nov 13 00:38:13 2006 +0000
     1.2 +++ b/src/video/xbios/SDL_xbios.c	Mon Nov 13 19:59:28 2006 +0000
     1.3 @@ -46,9 +46,7 @@
     1.4  #include "../ataricommon/SDL_atarimxalloc_c.h"
     1.5  #include "../ataricommon/SDL_atarigl_c.h"
     1.6  #include "SDL_xbios.h"
     1.7 -#include "SDL_xbios_blowup.h"
     1.8 -#include "SDL_xbios_centscreen.h"
     1.9 -#include "SDL_xbios_sb3.h"
    1.10 +#include "SDL_xbiosmodes.h"
    1.11  
    1.12  /* Debug print info */
    1.13  #if 0
    1.14 @@ -66,34 +64,6 @@
    1.15  static int XBIOS_VideoInit(_THIS);
    1.16  static void XBIOS_VideoQuit(_THIS);
    1.17  
    1.18 -#if 0
    1.19 -static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat * format,
    1.20 -                                  Uint32 flags);
    1.21 -static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface * current,
    1.22 -                                       int width, int height, int bpp,
    1.23 -                                       Uint32 flags);
    1.24 -static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors,
    1.25 -                           SDL_Color * colors);
    1.26 -
    1.27 -/* Hardware surface functions */
    1.28 -static int XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface);
    1.29 -static int XBIOS_LockHWSurface(_THIS, SDL_Surface * surface);
    1.30 -static int XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface);
    1.31 -static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface * surface);
    1.32 -static void XBIOS_FreeHWSurface(_THIS, SDL_Surface * surface);
    1.33 -static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
    1.34 -
    1.35 -#if SDL_VIDEO_OPENGL
    1.36 -/* OpenGL functions */
    1.37 -static void XBIOS_GL_SwapBuffers(_THIS);
    1.38 -#endif
    1.39 -
    1.40 -/* To setup palette */
    1.41 -
    1.42 -static unsigned short TT_palette[256];
    1.43 -static unsigned long F30_palette[256];
    1.44 -#endif
    1.45 -
    1.46  /* Xbios driver bootstrap functions */
    1.47  
    1.48  static int
    1.49 @@ -126,11 +96,11 @@
    1.50      case VDO_F30:
    1.51          if (VgetMonitor() == MONITOR_MONO)
    1.52              return 0;
    1.53 -        if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
    1.54 +        /*if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
    1.55              if (!SDL_XBIOS_SB3Usable((scpn_cookie_t *) cookie_scpn)) {
    1.56                  return 0;
    1.57              }
    1.58 -        }
    1.59 +        }*/
    1.60          break;
    1.61      default:
    1.62          return 0;
    1.63 @@ -171,8 +141,8 @@
    1.64      device->VideoQuit = XBIOS_VideoQuit;
    1.65  
    1.66      /* Modes */
    1.67 -    device->GetDisplayModes = NULL /*XBIOS_GetDisplayModes */ ;
    1.68 -    device->SetDisplayMode = NULL /*XBIOS_SetDisplayMode */ ;
    1.69 +    device->GetDisplayModes = SDL_XBIOS_GetDisplayModes;
    1.70 +    device->SetDisplayMode = SDL_XBIOS_SetDisplayMode;
    1.71  
    1.72      /* Events */
    1.73      device->PumpEvents = SDL_Atari_PumpEvents;
    1.74 @@ -199,294 +169,13 @@
    1.75      XBIOS_Available, XBIOS_CreateDevice
    1.76  };
    1.77  
    1.78 -#if 0
    1.79 -void
    1.80 -SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height,
    1.81 -                  Uint16 depth, SDL_bool flags)
    1.82 -{
    1.83 -    int i, curpos;
    1.84 -    xbiosmode_t *current_mode;
    1.85 -
    1.86 -    /* Check if mode already exists */
    1.87 -    if (XBIOS_modelist) {
    1.88 -        current_mode = XBIOS_modelist;
    1.89 -        for (i = 0; i < XBIOS_nummodes; i++, current_mode++) {
    1.90 -            if (current_mode->width != width)
    1.91 -                continue;
    1.92 -            if (current_mode->height != height)
    1.93 -                continue;
    1.94 -            if (current_mode->depth != depth)
    1.95 -                continue;
    1.96 -            return;
    1.97 -        }
    1.98 -    }
    1.99 -
   1.100 -    ++XBIOS_nummodes;
   1.101 -    XBIOS_modelist =
   1.102 -        (xbiosmode_t *) SDL_realloc(XBIOS_modelist,
   1.103 -                                    XBIOS_nummodes * sizeof(xbiosmode_t));
   1.104 -
   1.105 -    /* Keep the list sorted: bpp, width, height */
   1.106 -    curpos = 0;
   1.107 -
   1.108 -    for (i = 0; i < XBIOS_nummodes - 1; i++) {
   1.109 -        if (XBIOS_modelist[i].depth <= depth) {
   1.110 -            if (XBIOS_modelist[i].width < width) {
   1.111 -                break;
   1.112 -            } else if (XBIOS_modelist[i].width == width) {
   1.113 -                if (XBIOS_modelist[i].height <= height) {
   1.114 -                    break;
   1.115 -                }
   1.116 -            }
   1.117 -        }
   1.118 -        curpos++;
   1.119 -    }
   1.120 -
   1.121 -    /* Push remaining modes further */
   1.122 -    for (i = XBIOS_nummodes - 1; i > curpos; i--) {
   1.123 -        SDL_memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i - 1],
   1.124 -                   sizeof(xbiosmode_t));
   1.125 -    }
   1.126 -
   1.127 -    XBIOS_modelist[curpos].number = modecode;
   1.128 -    XBIOS_modelist[curpos].width = width;
   1.129 -    XBIOS_modelist[curpos].height = height;
   1.130 -    XBIOS_modelist[curpos].depth = depth;
   1.131 -    XBIOS_modelist[curpos].doubleline = flags;
   1.132 -}
   1.133 -#endif
   1.134 -
   1.135  static int
   1.136  XBIOS_VideoInit(_THIS)
   1.137  {
   1.138 -    XBIOS_InitModes(_this);
   1.139 +    /* Save screensaver settings */
   1.140  
   1.141 -#if 0
   1.142 -    int i, j8, j16;
   1.143 -    xbiosmode_t *current_mode;
   1.144 -    unsigned long cookie_blow, cookie_scpn, cookie_cnts;
   1.145 -
   1.146 -    /* Initialize all variables that we clean on shutdown */
   1.147 -    memset(SDL_modelist, 0, sizeof(SDL_modelist));
   1.148 -
   1.149 -    /* Cookie _VDO present ? if not, assume ST machine */
   1.150 -    if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
   1.151 -        XBIOS_cvdo = VDO_ST << 16;
   1.152 -    }
   1.153 -
   1.154 -    /* Allocate memory for old palette */
   1.155 -    XBIOS_oldpalette = (void *) SDL_malloc(256 * sizeof(long));
   1.156 -    if (!XBIOS_oldpalette) {
   1.157 -        SDL_SetError("Unable to allocate memory for old palette\n");
   1.158 -        return (-1);
   1.159 -    }
   1.160 -
   1.161 -    /* Initialize video mode list */
   1.162 -    /* and save current screen status (palette, screen address, video mode) */
   1.163 -    XBIOS_nummodes = 0;
   1.164 -    XBIOS_modelist = NULL;
   1.165 -    XBIOS_centscreen = SDL_FALSE;
   1.166 -
   1.167 -    switch (XBIOS_cvdo >> 16) {
   1.168 -    case VDO_ST:
   1.169 -    case VDO_STE:
   1.170 -        {
   1.171 -            short *oldpalette;
   1.172 -
   1.173 -            SDL_XBIOS_AddMode(this, ST_LOW >> 8, 320, 200, 4, SDL_FALSE);
   1.174 -
   1.175 -            XBIOS_oldvbase = Physbase();
   1.176 -            XBIOS_oldvmode = Getrez();
   1.177 -            switch (XBIOS_oldvmode << 8) {
   1.178 -            case ST_LOW:
   1.179 -                XBIOS_oldnumcol = 16;
   1.180 -                break;
   1.181 -            case ST_MED:
   1.182 -                XBIOS_oldnumcol = 4;
   1.183 -                break;
   1.184 -            case ST_HIGH:
   1.185 -                XBIOS_oldnumcol = 2;
   1.186 -                break;
   1.187 -            default:
   1.188 -                XBIOS_oldnumcol = 0;
   1.189 -                break;
   1.190 -            }
   1.191 -
   1.192 -            oldpalette = (short *) XBIOS_oldpalette;
   1.193 -            for (i = 0; i < XBIOS_oldnumcol; i++) {
   1.194 -                *oldpalette++ = Setcolor(i, -1);
   1.195 -            }
   1.196 -
   1.197 -            vformat->BitsPerPixel = 8;
   1.198 -        }
   1.199 -        break;
   1.200 -    case VDO_TT:
   1.201 -
   1.202 -        SDL_XBIOS_AddMode(this, TT_LOW, 320, 480, 8, SDL_FALSE);
   1.203 -        /* Software double-lined mode */
   1.204 -        SDL_XBIOS_AddMode(this, TT_LOW, 320, 240, 8, SDL_TRUE);
   1.205 -
   1.206 -        XBIOS_oldvbase = Logbase();
   1.207 -        XBIOS_oldvmode = EgetShift();
   1.208 -
   1.209 -        switch (XBIOS_oldvmode & ES_MODE) {
   1.210 -        case TT_LOW:
   1.211 -            XBIOS_oldnumcol = 256;
   1.212 -            break;
   1.213 -        case ST_LOW:
   1.214 -        case TT_MED:
   1.215 -            XBIOS_oldnumcol = 16;
   1.216 -            break;
   1.217 -        case ST_MED:
   1.218 -            XBIOS_oldnumcol = 4;
   1.219 -            break;
   1.220 -        case ST_HIGH:
   1.221 -        case TT_HIGH:
   1.222 -            XBIOS_oldnumcol = 2;
   1.223 -            break;
   1.224 -        default:
   1.225 -            XBIOS_oldnumcol = 0;
   1.226 -            break;
   1.227 -        }
   1.228 -        if (XBIOS_oldnumcol) {
   1.229 -            EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
   1.230 -        }
   1.231 -
   1.232 -        vformat->BitsPerPixel = 8;
   1.233 -        break;
   1.234 -    case VDO_F30:
   1.235 -        switch (VgetMonitor()) {
   1.236 -        case MONITOR_MONO:
   1.237 -            /* Not usable */
   1.238 -            break;
   1.239 -        case MONITOR_RGB:
   1.240 -        case MONITOR_TV:
   1.241 -            SDL_XBIOS_AddMode(this, BPS16 | COL80 | OVERSCAN | VERTFLAG,
   1.242 -                              768, 480, 16, SDL_FALSE);
   1.243 -            SDL_XBIOS_AddMode(this, BPS16 | COL80 | OVERSCAN, 768, 240,
   1.244 -                              16, SDL_FALSE);
   1.245 -            SDL_XBIOS_AddMode(this, BPS16 | COL80 | VERTFLAG, 640, 400,
   1.246 -                              16, SDL_FALSE);
   1.247 -            SDL_XBIOS_AddMode(this, BPS16 | COL80, 640, 200, 16, SDL_FALSE);
   1.248 -            SDL_XBIOS_AddMode(this, BPS16 | OVERSCAN | VERTFLAG, 384,
   1.249 -                              480, 16, SDL_FALSE);
   1.250 -            SDL_XBIOS_AddMode(this, BPS16 | OVERSCAN, 384, 240, 16,
   1.251 -                              SDL_FALSE);
   1.252 -            SDL_XBIOS_AddMode(this, BPS16 | VERTFLAG, 320, 400, 16,
   1.253 -                              SDL_FALSE);
   1.254 -            SDL_XBIOS_AddMode(this, BPS16, 320, 200, 16, SDL_FALSE);
   1.255 -            SDL_XBIOS_AddMode(this, BPS8 | COL80 | OVERSCAN | VERTFLAG,
   1.256 -                              768, 480, 8, SDL_FALSE);
   1.257 -            SDL_XBIOS_AddMode(this, BPS8 | COL80 | OVERSCAN, 768, 240, 8,
   1.258 -                              SDL_FALSE);
   1.259 -            SDL_XBIOS_AddMode(this, BPS8 | COL80 | VERTFLAG, 640, 400, 8,
   1.260 -                              SDL_FALSE);
   1.261 -            SDL_XBIOS_AddMode(this, BPS8 | COL80, 640, 200, 8, SDL_FALSE);
   1.262 -            SDL_XBIOS_AddMode(this, BPS8 | OVERSCAN | VERTFLAG, 384, 480,
   1.263 -                              8, SDL_FALSE);
   1.264 -            SDL_XBIOS_AddMode(this, BPS8 | OVERSCAN, 384, 240, 8, SDL_FALSE);
   1.265 -            SDL_XBIOS_AddMode(this, BPS8 | VERTFLAG, 320, 400, 8, SDL_FALSE);
   1.266 -            SDL_XBIOS_AddMode(this, BPS8, 320, 200, 8, SDL_FALSE);
   1.267 -            break;
   1.268 -        case MONITOR_VGA:
   1.269 -            SDL_XBIOS_AddMode(this, BPS16, 320, 480, 16, SDL_FALSE);
   1.270 -            SDL_XBIOS_AddMode(this, BPS16 | VERTFLAG, 320, 240, 16,
   1.271 -                              SDL_FALSE);
   1.272 -            SDL_XBIOS_AddMode(this, BPS8 | COL80, 640, 480, 8, SDL_FALSE);
   1.273 -            SDL_XBIOS_AddMode(this, BPS8 | COL80 | VERTFLAG, 640, 240, 8,
   1.274 -                              SDL_FALSE);
   1.275 -            SDL_XBIOS_AddMode(this, BPS8, 320, 480, 8, SDL_FALSE);
   1.276 -            SDL_XBIOS_AddMode(this, BPS8 | VERTFLAG, 320, 240, 8, SDL_FALSE);
   1.277 -            break;
   1.278 -        }
   1.279 -        XBIOS_oldvbase = Logbase();
   1.280 -        XBIOS_oldvmode = VsetMode(-1);
   1.281 -
   1.282 -        XBIOS_oldnumcol = 1 << (1 << (XBIOS_oldvmode & NUMCOLS));
   1.283 -        if (XBIOS_oldnumcol > 256) {
   1.284 -            XBIOS_oldnumcol = 0;
   1.285 -        }
   1.286 -        if (XBIOS_oldnumcol) {
   1.287 -            VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
   1.288 -        }
   1.289 -
   1.290 -        vformat->BitsPerPixel = 16;
   1.291 -
   1.292 -        /* Keep vga/rvb, and pal/ntsc bits */
   1.293 -        current_mode = XBIOS_modelist;
   1.294 -        for (i = 0; i < XBIOS_nummodes; i++) {
   1.295 -            Uint16 newvmode;
   1.296 -
   1.297 -            newvmode = current_mode->number;
   1.298 -            newvmode &= ~(VGA | PAL);
   1.299 -            newvmode |= XBIOS_oldvmode & (VGA | PAL);
   1.300 -            current_mode->number = newvmode;
   1.301 -
   1.302 -            current_mode++;
   1.303 -        }
   1.304 -
   1.305 -        /* Initialize BlowUp/SB3/Centscreen stuff if present */
   1.306 -        if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) {
   1.307 -            SDL_XBIOS_BlowupInit(this, (blow_cookie_t *) cookie_blow);
   1.308 -        } else if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
   1.309 -            SDL_XBIOS_SB3Init(this, (scpn_cookie_t *) cookie_scpn);
   1.310 -        } else if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) {
   1.311 -            XBIOS_oldvmode = SDL_XBIOS_CentscreenInit(this);
   1.312 -            XBIOS_centscreen = SDL_TRUE;
   1.313 -        }
   1.314 -
   1.315 -        break;
   1.316 -    }
   1.317 -
   1.318 -    /* Determine the current screen size */
   1.319 -    if (XBIOS_nummodes > 0) {
   1.320 -        /* FIXME: parse video mode list to search for current mode */
   1.321 -        this->info.current_w = XBIOS_modelist[0].width;
   1.322 -        this->info.current_h = XBIOS_modelist[0].height;
   1.323 -    }
   1.324 -
   1.325 -    current_mode = XBIOS_modelist;
   1.326 -    j8 = j16 = 0;
   1.327 -    for (i = 0; i < XBIOS_nummodes; i++, current_mode++) {
   1.328 -        switch (current_mode->depth) {
   1.329 -        case 4:
   1.330 -        case 8:
   1.331 -            SDL_modelist[0][j8] = SDL_malloc(sizeof(SDL_Rect));
   1.332 -            SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0;
   1.333 -            SDL_modelist[0][j8]->w = current_mode->width;
   1.334 -            SDL_modelist[0][j8]->h = current_mode->height;
   1.335 -            XBIOS_videomodes[0][j8] = current_mode;
   1.336 -            j8++;
   1.337 -            break;
   1.338 -        case 16:
   1.339 -            SDL_modelist[1][j16] = SDL_malloc(sizeof(SDL_Rect));
   1.340 -            SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0;
   1.341 -            SDL_modelist[1][j16]->w = current_mode->width;
   1.342 -            SDL_modelist[1][j16]->h = current_mode->height;
   1.343 -            XBIOS_videomodes[1][j16] = current_mode;
   1.344 -            j16++;
   1.345 -            break;
   1.346 -        }
   1.347 -    }
   1.348 -    SDL_modelist[0][j8] = NULL;
   1.349 -    SDL_modelist[1][j16] = NULL;
   1.350 -
   1.351 -    XBIOS_screens[0] = NULL;
   1.352 -    XBIOS_screens[1] = NULL;
   1.353 -    XBIOS_shadowscreen = NULL;
   1.354 -
   1.355 -    /* Update hardware info */
   1.356 -    this->info.hw_available = 1;
   1.357 -    this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM);
   1.358 -
   1.359 -    /* Init chunky to planar routine */
   1.360 -    SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
   1.361 -
   1.362 -#if SDL_VIDEO_OPENGL
   1.363 -    SDL_AtariGL_InitPointers(this);
   1.364 -#endif
   1.365 -
   1.366 -#endif
   1.367 +    /* Init video mode list */
   1.368 +    SDL_XBIOS_InitModes(_this);
   1.369  
   1.370      return (0);
   1.371  }
   1.372 @@ -494,487 +183,9 @@
   1.373  static void
   1.374  XBIOS_VideoQuit(_THIS)
   1.375  {
   1.376 -/*    int i, j;*/
   1.377 -
   1.378 -    XBIOS_QuitModes(_this);
   1.379      Atari_ShutdownEvents();
   1.380  
   1.381 -#if 0
   1.382 -    /* Restore video mode and palette */
   1.383 -#ifndef DEBUG_VIDEO_XBIOS
   1.384 -    switch (XBIOS_cvdo >> 16) {
   1.385 -    case VDO_ST:
   1.386 -    case VDO_STE:
   1.387 -        Setscreen(-1, XBIOS_oldvbase, XBIOS_oldvmode);
   1.388 -        if (XBIOS_oldnumcol) {
   1.389 -            Setpalette(XBIOS_oldpalette);
   1.390 -        }
   1.391 -        break;
   1.392 -    case VDO_TT:
   1.393 -        Setscreen(-1, XBIOS_oldvbase, -1);
   1.394 -        EsetShift(XBIOS_oldvmode);
   1.395 -        if (XBIOS_oldnumcol) {
   1.396 -            EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
   1.397 -        }
   1.398 -        break;
   1.399 -    case VDO_F30:
   1.400 -        Setscreen(-1, XBIOS_oldvbase, -1);
   1.401 -        if (XBIOS_centscreen) {
   1.402 -            SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode);
   1.403 -        } else {
   1.404 -            VsetMode(XBIOS_oldvmode);
   1.405 -        }
   1.406 -        if (XBIOS_oldnumcol) {
   1.407 -            VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
   1.408 -        }
   1.409 -        break;
   1.410 -    }
   1.411 -    Vsync();
   1.412 -#endif
   1.413 +    /* Restore screensaver settings */
   1.414  
   1.415 -
   1.416 -#if SDL_VIDEO_OPENGL
   1.417 -    if (gl_active) {
   1.418 -        SDL_AtariGL_Quit(this, SDL_TRUE);
   1.419 -    }
   1.420 -#endif
   1.421 -
   1.422 -    if (XBIOS_oldpalette) {
   1.423 -        SDL_free(XBIOS_oldpalette);
   1.424 -        XBIOS_oldpalette = NULL;
   1.425 -    }
   1.426 -    XBIOS_FreeBuffers(this);
   1.427 -
   1.428 -    /* Free mode list */
   1.429 -    for (j = 0; j < NUM_MODELISTS; j++) {
   1.430 -        for (i = 0; i < SDL_NUMMODES; i++) {
   1.431 -            if (SDL_modelist[j][i] != NULL) {
   1.432 -                SDL_free(SDL_modelist[j][i]);
   1.433 -                SDL_modelist[j][i] = NULL;
   1.434 -            }
   1.435 -        }
   1.436 -    }
   1.437 -
   1.438 -    if (XBIOS_modelist) {
   1.439 -        SDL_free(XBIOS_modelist);
   1.440 -        XBIOS_nummodes = 0;
   1.441 -        XBIOS_modelist = NULL;
   1.442 -    }
   1.443 -
   1.444 -    this->screen->pixels = NULL;
   1.445 -#endif
   1.446 +    SDL_XBIOS_QuitModes(_this);
   1.447  }
   1.448 -
   1.449 -#if 0
   1.450 -static SDL_Rect **
   1.451 -XBIOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.452 -{
   1.453 -    /* 8 bits -> list 0 */
   1.454 -    /* 16 bits -> list 1 */
   1.455 -    if ((format->BitsPerPixel != 8) && (format->BitsPerPixel != 16)) {
   1.456 -        return NULL;
   1.457 -    }
   1.458 -
   1.459 -    return (SDL_modelist[(format->BitsPerPixel) >> 4]);
   1.460 -}
   1.461 -
   1.462 -static void
   1.463 -XBIOS_FreeBuffers(_THIS)
   1.464 -{
   1.465 -    int i;
   1.466 -
   1.467 -    for (i = 0; i < 2; i++) {
   1.468 -        if (XBIOS_screensmem[i] != NULL) {
   1.469 -            Mfree(XBIOS_screensmem[i]);
   1.470 -            XBIOS_screensmem[i] = NULL;
   1.471 -        }
   1.472 -    }
   1.473 -
   1.474 -    if (XBIOS_shadowscreen != NULL) {
   1.475 -        Mfree(XBIOS_shadowscreen);
   1.476 -        XBIOS_shadowscreen = NULL;
   1.477 -    }
   1.478 -}
   1.479 -
   1.480 -static SDL_Surface *
   1.481 -XBIOS_SetVideoMode(_THIS, SDL_Surface * current,
   1.482 -                   int width, int height, int bpp, Uint32 flags)
   1.483 -{
   1.484 -    int mode, new_depth;
   1.485 -    int i;
   1.486 -    xbiosmode_t *new_video_mode;
   1.487 -    Uint32 new_screen_size;
   1.488 -    Uint32 modeflags;
   1.489 -
   1.490 -    /* Free current buffers */
   1.491 -    XBIOS_FreeBuffers(this);
   1.492 -
   1.493 -    /* Limit bpp */
   1.494 -    if (bpp > 16) {
   1.495 -        bpp = 16;
   1.496 -    }
   1.497 -    bpp >>= 4;
   1.498 -
   1.499 -    /* Search if the mode exists (width, height, bpp) */
   1.500 -    for (mode = 0; SDL_modelist[bpp][mode]; ++mode) {
   1.501 -        if ((SDL_modelist[bpp][mode]->w == width) &&
   1.502 -            (SDL_modelist[bpp][mode]->h == height)) {
   1.503 -
   1.504 -            break;
   1.505 -        }
   1.506 -    }
   1.507 -    if (SDL_modelist[bpp][mode] == NULL) {
   1.508 -        SDL_SetError("Couldn't find requested mode in list");
   1.509 -        return (NULL);
   1.510 -    }
   1.511 -
   1.512 -    modeflags = SDL_FULLSCREEN | SDL_PREALLOC;
   1.513 -
   1.514 -    /* Allocate needed buffers: simple/double buffer and shadow surface */
   1.515 -    new_video_mode = XBIOS_videomodes[bpp][mode];
   1.516 -    new_depth = new_video_mode->depth;
   1.517 -    if (new_depth == 4) {
   1.518 -        SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4;
   1.519 -        new_depth = 8;
   1.520 -        modeflags |= SDL_SWSURFACE | SDL_HWPALETTE;
   1.521 -    } else if (new_depth == 8) {
   1.522 -        SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
   1.523 -        modeflags |= SDL_SWSURFACE | SDL_HWPALETTE;
   1.524 -    } else {
   1.525 -        modeflags |= SDL_HWSURFACE;
   1.526 -    }
   1.527 -
   1.528 -    new_screen_size = width * height * ((new_depth) >> 3);
   1.529 -    new_screen_size += 256;     /* To align on a 256 byte adress */
   1.530 -
   1.531 -    if (new_depth == 8) {
   1.532 -        XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM);
   1.533 -
   1.534 -        if (XBIOS_shadowscreen == NULL) {
   1.535 -            SDL_SetError("Can not allocate %d KB for shadow buffer",
   1.536 -                         new_screen_size >> 10);
   1.537 -            return (NULL);
   1.538 -        }
   1.539 -        SDL_memset(XBIOS_shadowscreen, 0, new_screen_size);
   1.540 -    }
   1.541 -
   1.542 -    /* Output buffer needs to be twice in size for the software double-line mode */
   1.543 -    XBIOS_doubleline = SDL_FALSE;
   1.544 -    if (new_video_mode->doubleline) {
   1.545 -        new_screen_size <<= 1;
   1.546 -        XBIOS_doubleline = SDL_TRUE;
   1.547 -    }
   1.548 -
   1.549 -    XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM);
   1.550 -
   1.551 -    if (XBIOS_screensmem[0] == NULL) {
   1.552 -        XBIOS_FreeBuffers(this);
   1.553 -        SDL_SetError("Can not allocate %d KB for frame buffer",
   1.554 -                     new_screen_size >> 10);
   1.555 -        return (NULL);
   1.556 -    }
   1.557 -    SDL_memset(XBIOS_screensmem[0], 0, new_screen_size);
   1.558 -
   1.559 -    XBIOS_screens[0] =
   1.560 -        (void *) (((long) XBIOS_screensmem[0] + 256) & 0xFFFFFF00UL);
   1.561 -
   1.562 -#if SDL_VIDEO_OPENGL
   1.563 -    if (flags & SDL_INTERNALOPENGL) {
   1.564 -        if (this->gl_config.double_buffer) {
   1.565 -            flags |= SDL_DOUBLEBUF;
   1.566 -        }
   1.567 -    }
   1.568 -#endif
   1.569 -
   1.570 -    /* Double buffer ? */
   1.571 -    if (flags & SDL_DOUBLEBUF) {
   1.572 -        XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM);
   1.573 -
   1.574 -        if (XBIOS_screensmem[1] == NULL) {
   1.575 -            XBIOS_FreeBuffers(this);
   1.576 -            SDL_SetError("Can not allocate %d KB for double buffer",
   1.577 -                         new_screen_size >> 10);
   1.578 -            return (NULL);
   1.579 -        }
   1.580 -        SDL_memset(XBIOS_screensmem[1], 0, new_screen_size);
   1.581 -
   1.582 -        XBIOS_screens[1] =
   1.583 -            (void *) (((long) XBIOS_screensmem[1] + 256) & 0xFFFFFF00UL);
   1.584 -        modeflags |= SDL_DOUBLEBUF;
   1.585 -    }
   1.586 -
   1.587 -    /* Allocate the new pixel format for the screen */
   1.588 -    if (!SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0)) {
   1.589 -        XBIOS_FreeBuffers(this);
   1.590 -        SDL_SetError("Couldn't allocate new pixel format for requested mode");
   1.591 -        return (NULL);
   1.592 -    }
   1.593 -
   1.594 -    current->w = XBIOS_width = width;
   1.595 -    current->h = XBIOS_height = height;
   1.596 -    current->pitch = (width * new_depth) >> 3;
   1.597 -
   1.598 -    /* this is for C2P conversion */
   1.599 -    XBIOS_pitch = (new_video_mode->width * new_video_mode->depth) >> 3;
   1.600 -
   1.601 -    if (new_depth == 8)
   1.602 -        current->pixels = XBIOS_shadowscreen;
   1.603 -    else
   1.604 -        current->pixels = XBIOS_screens[0];
   1.605 -
   1.606 -    XBIOS_fbnum = 0;
   1.607 -
   1.608 -#if SDL_VIDEO_OPENGL
   1.609 -    if (flags & SDL_INTERNALOPENGL) {
   1.610 -        if (!SDL_AtariGL_Init(this, current)) {
   1.611 -            XBIOS_FreeBuffers(this);
   1.612 -            SDL_SetError("Can not create OpenGL context");
   1.613 -            return NULL;
   1.614 -        }
   1.615 -
   1.616 -        modeflags |= SDL_INTERNALOPENGL;
   1.617 -    }
   1.618 -#endif
   1.619 -
   1.620 -    current->flags = modeflags;
   1.621 -
   1.622 -    /* Now set the video mode */
   1.623 -#ifndef DEBUG_VIDEO_XBIOS
   1.624 -    Setscreen(-1, XBIOS_screens[0], -1);
   1.625 -#endif
   1.626 -
   1.627 -    switch (XBIOS_cvdo >> 16) {
   1.628 -    case VDO_ST:
   1.629 -#ifndef DEBUG_VIDEO_XBIOS
   1.630 -        Setscreen(-1, -1, new_video_mode->number);
   1.631 -#endif
   1.632 -        /* Reset palette */
   1.633 -        for (i = 0; i < 16; i++) {
   1.634 -            TT_palette[i] =
   1.635 -                ((i >> 1) << 8) | (((i * 8) / 17) << 4) | (i >> 1);
   1.636 -        }
   1.637 -#ifndef DEBUG_VIDEO_XBIOS
   1.638 -        Setpalette(TT_palette);
   1.639 -#endif
   1.640 -        break;
   1.641 -    case VDO_STE:
   1.642 -#ifndef DEBUG_VIDEO_XBIOS
   1.643 -        Setscreen(-1, -1, new_video_mode->number);
   1.644 -#endif
   1.645 -        /* Reset palette */
   1.646 -        for (i = 0; i < 16; i++) {
   1.647 -            int c;
   1.648 -
   1.649 -            c = ((i & 1) << 3) | ((i >> 1) & 7);
   1.650 -            TT_palette[i] = (c << 8) | (c << 4) | c;
   1.651 -        }
   1.652 -#ifndef DEBUG_VIDEO_XBIOS
   1.653 -        Setpalette(TT_palette);
   1.654 -#endif
   1.655 -        break;
   1.656 -    case VDO_TT:
   1.657 -#ifndef DEBUG_VIDEO_XBIOS
   1.658 -        EsetShift(new_video_mode->number);
   1.659 -#endif
   1.660 -        break;
   1.661 -    case VDO_F30:
   1.662 -#ifndef DEBUG_VIDEO_XBIOS
   1.663 -        if (XBIOS_centscreen) {
   1.664 -            SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth);
   1.665 -        } else {
   1.666 -            VsetMode(new_video_mode->number);
   1.667 -        }
   1.668 -#endif
   1.669 -        /* Set hardware palette to black in True Colour */
   1.670 -        if (new_depth == 16) {
   1.671 -            SDL_memset(F30_palette, 0, sizeof(F30_palette));
   1.672 -            VsetRGB(0, 256, F30_palette);
   1.673 -        }
   1.674 -        break;
   1.675 -    }
   1.676 -
   1.677 -    Vsync();
   1.678 -
   1.679 -    this->UpdateRects = XBIOS_UpdateRects;
   1.680 -
   1.681 -    return (current);
   1.682 -}
   1.683 -
   1.684 -/* We don't actually allow hardware surfaces other than the main one */
   1.685 -static int
   1.686 -XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface)
   1.687 -{
   1.688 -    return (-1);
   1.689 -}
   1.690 -
   1.691 -static void
   1.692 -XBIOS_FreeHWSurface(_THIS, SDL_Surface * surface)
   1.693 -{
   1.694 -    return;
   1.695 -}
   1.696 -
   1.697 -static int
   1.698 -XBIOS_LockHWSurface(_THIS, SDL_Surface * surface)
   1.699 -{
   1.700 -    return (0);
   1.701 -}
   1.702 -
   1.703 -static void
   1.704 -XBIOS_UnlockHWSurface(_THIS, SDL_Surface * surface)
   1.705 -{
   1.706 -    return;
   1.707 -}
   1.708 -
   1.709 -static void
   1.710 -XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
   1.711 -{
   1.712 -    SDL_Surface *surface;
   1.713 -
   1.714 -    surface = this->screen;
   1.715 -
   1.716 -    if ((surface->format->BitsPerPixel) == 8) {
   1.717 -        int i;
   1.718 -
   1.719 -        for (i = 0; i < numrects; i++) {
   1.720 -            void *source, *destination;
   1.721 -            int x1, x2;
   1.722 -
   1.723 -            x1 = rects[i].x & ~15;
   1.724 -            x2 = rects[i].x + rects[i].w;
   1.725 -            if (x2 & 15) {
   1.726 -                x2 = (x2 | 15) + 1;
   1.727 -            }
   1.728 -
   1.729 -            source = surface->pixels;
   1.730 -            source += surface->pitch * rects[i].y;
   1.731 -            source += x1;
   1.732 -
   1.733 -            destination = XBIOS_screens[XBIOS_fbnum];
   1.734 -            destination += XBIOS_pitch * rects[i].y;
   1.735 -            destination += x1;
   1.736 -
   1.737 -            /* Convert chunky to planar screen */
   1.738 -            SDL_Atari_C2pConvert(source,
   1.739 -                                 destination,
   1.740 -                                 x2 - x1,
   1.741 -                                 rects[i].h,
   1.742 -                                 XBIOS_doubleline,
   1.743 -                                 surface->pitch, XBIOS_pitch);
   1.744 -        }
   1.745 -    }
   1.746 -#ifndef DEBUG_VIDEO_XBIOS
   1.747 -    Setscreen(-1, XBIOS_screens[XBIOS_fbnum], -1);
   1.748 -#endif
   1.749 -    Vsync();
   1.750 -
   1.751 -    if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   1.752 -        XBIOS_fbnum ^= 1;
   1.753 -        if ((surface->format->BitsPerPixel) > 8) {
   1.754 -            surface->pixels = XBIOS_screens[XBIOS_fbnum];
   1.755 -        }
   1.756 -    }
   1.757 -}
   1.758 -
   1.759 -static int
   1.760 -XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface)
   1.761 -{
   1.762 -    if ((surface->format->BitsPerPixel) == 8) {
   1.763 -        void *destscr;
   1.764 -        int destx;
   1.765 -
   1.766 -        /* Center on destination screen */
   1.767 -        destscr = XBIOS_screens[XBIOS_fbnum];
   1.768 -        destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
   1.769 -        destx = (XBIOS_width - surface->w) >> 1;
   1.770 -        destx &= ~15;
   1.771 -        destscr += destx;
   1.772 -
   1.773 -        /* Convert chunky to planar screen */
   1.774 -        SDL_Atari_C2pConvert(surface->pixels,
   1.775 -                             destscr,
   1.776 -                             surface->w,
   1.777 -                             surface->h,
   1.778 -                             XBIOS_doubleline, surface->pitch, XBIOS_pitch);
   1.779 -    }
   1.780 -#ifndef DEBUG_VIDEO_XBIOS
   1.781 -    Setscreen(-1, XBIOS_screens[XBIOS_fbnum], -1);
   1.782 -#endif
   1.783 -    Vsync();
   1.784 -
   1.785 -    if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   1.786 -        XBIOS_fbnum ^= 1;
   1.787 -        if ((surface->format->BitsPerPixel) > 8) {
   1.788 -            surface->pixels = XBIOS_screens[XBIOS_fbnum];
   1.789 -        }
   1.790 -    }
   1.791 -
   1.792 -    return (0);
   1.793 -}
   1.794 -
   1.795 -static int
   1.796 -XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   1.797 -{
   1.798 -    int i;
   1.799 -    int r, v, b;
   1.800 -
   1.801 -    switch (XBIOS_cvdo >> 16) {
   1.802 -    case VDO_ST:
   1.803 -    case VDO_STE:
   1.804 -        for (i = 0; i < ncolors; i++) {
   1.805 -            r = colors[i].r;
   1.806 -            v = colors[i].g;
   1.807 -            b = colors[i].b;
   1.808 -
   1.809 -            TT_palette[firstcolor + i] =
   1.810 -                ((r * 30) + (v * 59) + (b * 11)) / 100;
   1.811 -        }
   1.812 -        SDL_Atari_C2pConvert4_pal(TT_palette);  /* convert the lighting */
   1.813 -        break;
   1.814 -    case VDO_TT:
   1.815 -        for (i = 0; i < ncolors; i++) {
   1.816 -            r = colors[i].r;
   1.817 -            v = colors[i].g;
   1.818 -            b = colors[i].b;
   1.819 -
   1.820 -            TT_palette[i] = ((r >> 4) << 8) | ((v >> 4) << 4) | (b >> 4);
   1.821 -        }
   1.822 -#ifndef DEBUG_VIDEO_XBIOS
   1.823 -        EsetPalette(firstcolor, ncolors, TT_palette);
   1.824 -#endif
   1.825 -        break;
   1.826 -    case VDO_F30:
   1.827 -        for (i = 0; i < ncolors; i++) {
   1.828 -            r = colors[i].r;
   1.829 -            v = colors[i].g;
   1.830 -            b = colors[i].b;
   1.831 -
   1.832 -            F30_palette[i] = (r << 16) | (v << 8) | b;
   1.833 -        }
   1.834 -#ifndef DEBUG_VIDEO_XBIOS
   1.835 -        VsetRGB(firstcolor, ncolors, F30_palette);
   1.836 -#endif
   1.837 -        break;
   1.838 -    }
   1.839 -
   1.840 -    return (1);
   1.841 -}
   1.842 -#endif
   1.843 -
   1.844 -/* Note:  If we are terminated, this could be called in the middle of
   1.845 -   another SDL video routine -- notably UpdateRects.
   1.846 -*/
   1.847 -
   1.848 -#if 0
   1.849 -#if SDL_VIDEO_OPENGL
   1.850 -
   1.851 -static void
   1.852 -XBIOS_GL_SwapBuffers(_THIS)
   1.853 -{
   1.854 -    SDL_AtariGL_SwapBuffers(this);
   1.855 -    XBIOS_FlipHWSurface(this, this->screen);
   1.856 -    SDL_AtariGL_MakeCurrent(this);
   1.857 -}
   1.858 -
   1.859 -#endif
   1.860 -#endif
   1.861 -/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/video/xbios/SDL_xbios.h	Mon Nov 13 00:38:13 2006 +0000
     2.2 +++ b/src/video/xbios/SDL_xbios.h	Mon Nov 13 19:59:28 2006 +0000
     2.3 @@ -27,28 +27,11 @@
     2.4  #include "SDL_stdinc.h"
     2.5  #include "../SDL_sysvideo.h"
     2.6  
     2.7 -/* TT video modes:	2
     2.8 -   Falcon RVB:		16 (could be *2 by adding PAL/NTSC modes)
     2.9 -   Falcon VGA:		6
    2.10 -   ST low:		1
    2.11 -*/
    2.12 -#define SDL_NUMMODES 16
    2.13 -
    2.14 -typedef struct
    2.15 -{
    2.16 -    Uint16 number;              /* Video mode number */
    2.17 -    Uint16 width;               /* Size */
    2.18 -    Uint16 height;
    2.19 -    Uint16 depth;               /* bits per plane */
    2.20 -    SDL_bool doubleline;        /* Double the lines ? */
    2.21 -} xbiosmode_t;
    2.22 -
    2.23 -/* Private display data */
    2.24 -#define NUM_MODELISTS	2       /* 8 and 16 bits-per-pixel */
    2.25 -
    2.26  typedef struct SDL_VideoData
    2.27  {
    2.28      long cookie_vdo;
    2.29 +
    2.30 +#if 0
    2.31      int old_video_mode;         /* Old video mode before entering SDL */
    2.32      void *old_video_base;       /* Old pointer to screen buffer */
    2.33      void *old_palette;          /* Old palette */
    2.34 @@ -68,6 +51,7 @@
    2.35  
    2.36      SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES + 1];
    2.37      xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES + 1];
    2.38 +#endif
    2.39  } SDL_VideoData;
    2.40  
    2.41  /* _VDO cookie values */
    2.42 @@ -102,31 +86,5 @@
    2.43  #define TT_MED	0x0300
    2.44  #define TT_HIGH	0x0600
    2.45  
    2.46 -/* Hidden structure -> variables names */
    2.47 -#define SDL_modelist		(_this->driverdata->SDL_modelist)
    2.48 -#define XBIOS_mutex		    (_this->driverdata->mutex)
    2.49 -#define XBIOS_cvdo		    (_this->driverdata->cookie_vdo)
    2.50 -#define XBIOS_oldpalette	(_this->driverdata->old_palette)
    2.51 -#define XBIOS_oldnumcol		(_this->driverdata->old_num_colors)
    2.52 -#define XBIOS_oldvbase		(_this->driverdata->old_video_base)
    2.53 -#define XBIOS_oldvmode		(_this->driverdata->old_video_mode)
    2.54 -#define XBIOS_nummodes		(_this->driverdata->num_modes)
    2.55 -#define XBIOS_modelist		(_this->driverdata->mode_list)
    2.56 -#define XBIOS_screens		(_this->driverdata->screens)
    2.57 -#define XBIOS_screensmem	(_this->driverdata->screensmem)
    2.58 -#define XBIOS_shadowscreen	(_this->driverdata->shadowscreen)
    2.59 -#define XBIOS_videomodes	(_this->driverdata->videomodes)
    2.60 -#define XBIOS_doubleline	(_this->driverdata->doubleline)
    2.61 -#define XBIOS_fbnum			(_this->driverdata->frame_number)
    2.62 -#define XBIOS_pitch			(_this->driverdata->pitch)
    2.63 -#define XBIOS_width			(_this->driverdata->width)
    2.64 -#define XBIOS_height		(_this->driverdata->height)
    2.65 -#define XBIOS_centscreen	(_this->driverdata->centscreen)
    2.66 -
    2.67 -/*--- Functions prototypes ---*/
    2.68 -
    2.69 -void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height,
    2.70 -                       Uint16 depth, SDL_bool flags);
    2.71 -
    2.72  #endif /* _SDL_xbios_h */
    2.73  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/xbios/SDL_xbiosmodes.c	Mon Nov 13 19:59:28 2006 +0000
     3.3 @@ -0,0 +1,177 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2006 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +
    3.26 +#include <mint/osbind.h>
    3.27 +#include <mint/falcon.h>
    3.28 +
    3.29 +#include "SDL_config.h"
    3.30 +#include "SDL_xbios.h"
    3.31 +#include "SDL_xbiosmodes.h"
    3.32 +
    3.33 +
    3.34 +typedef struct {
    3.35 +    int width,height,bpp;
    3.36 +    int modecode;
    3.37 +    int doubleline;
    3.38 +} xbios_mode_t;
    3.39 +
    3.40 +static xbios_mode_t falcon_rgb_modes[]={
    3.41 +    {768, 480, 16, BPS16 | COL80 | OVERSCAN | VERTFLAG},
    3.42 +    {768, 240, 16, BPS16 | COL80 | OVERSCAN},
    3.43 +    {640, 400, 16, BPS16 | COL80 | VERTFLAG},
    3.44 +    {640, 200, 16, BPS16 | COL80},
    3.45 +    {384, 480, 16, BPS16 | OVERSCAN | VERTFLAG},
    3.46 +    {384, 240, 16, BPS16 | OVERSCAN},
    3.47 +    {320, 400, 16, BPS16 | VERTFLAG},
    3.48 +    {320, 200, 16, BPS16},
    3.49 +    {768, 480, 8, BPS8 | COL80 | OVERSCAN | VERTFLAG},
    3.50 +    {768, 240, 8, BPS8 | COL80 | OVERSCAN},
    3.51 +    {640, 400, 8, BPS8 | COL80 | VERTFLAG},
    3.52 +    {640, 200, 8, BPS8 | COL80},
    3.53 +    {384, 480, 8, BPS8 | OVERSCAN | VERTFLAG},
    3.54 +    {384, 240, 8, BPS8 | OVERSCAN},
    3.55 +    {320, 400, 8, BPS8 | VERTFLAG},
    3.56 +    {320, 200, 8, BPS8}
    3.57 +};
    3.58 + 
    3.59 +static xbios_mode_t falcon_vga_modes[]={
    3.60 +    {320, 480, 16, BPS16 },
    3.61 +    {320, 240, 16, BPS16 | VERTFLAG},
    3.62 +    {640, 480, 8, BPS8 | COL80},
    3.63 +    {640, 240, 8, BPS8 | COL80 | VERTFLAG},
    3.64 +    {320, 480, 8, BPS8 },
    3.65 +    {320, 240, 8, BPS8 | VERTFLAG}
    3.66 +};
    3.67 +
    3.68 +static void
    3.69 +SDL_XBIOS_AddMode(_THIS, int width, int height, int bpp, Uint16 modecode,
    3.70 +    SDL_bool doubleline)
    3.71 +{
    3.72 +    SDL_VideoDisplay display;
    3.73 +    SDL_DisplayData *displaydata;
    3.74 +    SDL_DisplayMode mode;
    3.75 +    Uint32 Rmask, Gmask, Bmask, Amask;
    3.76 +    int orig_bpp;
    3.77 +
    3.78 +    Rmask = Gmask = Bmask = Amask = 0;
    3.79 +    if (bpp == 16) {
    3.80 +        Rmask = 31<<11;
    3.81 +	Gmask = 63<<5;
    3.82 +	Bmask = 31;
    3.83 +    }
    3.84 +    /* Memorize for c2p4 operation */
    3.85 +    orig_bpp = bpp;
    3.86 +    if (bpp == 4) {
    3.87 +        bpp = 8;
    3.88 +    }
    3.89 +
    3.90 +    mode.format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
    3.91 +    mode.w = width;
    3.92 +    mode.h = height;
    3.93 +    mode.refresh_rate = 0;
    3.94 +    mode.driverdata = NULL;
    3.95 +
    3.96 +    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    3.97 +    if (!displaydata) {
    3.98 +       return;
    3.99 +    }
   3.100 +    displaydata->modecode = modecode;
   3.101 +    displaydata->doubleline = doubleline;
   3.102 +    displaydata->c2p4 = (orig_bpp == 4);
   3.103 +
   3.104 +    SDL_zero(display);
   3.105 +    display.desktop_mode = mode;
   3.106 +    display.current_mode = mode;
   3.107 +    display.driverdata = displaydata;
   3.108 +    SDL_AddVideoDisplay(&display);
   3.109 +}
   3.110 +
   3.111 +void
   3.112 +SDL_XBIOS_InitModes(_THIS)
   3.113 +{
   3.114 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   3.115 +
   3.116 +    switch (data->cookie_vdo >> 16) {
   3.117 +    case VDO_ST:
   3.118 +    case VDO_STE:
   3.119 +        {
   3.120 +            SDL_XBIOS_AddMode(_this, 320, 200, 4, ST_LOW >> 8, SDL_FALSE);
   3.121 +        }
   3.122 +        break;
   3.123 +    case VDO_TT:
   3.124 +        {
   3.125 +            SDL_XBIOS_AddMode(_this, 320, 480, 8, TT_LOW, SDL_FALSE);
   3.126 +            /* Software double-lined mode */
   3.127 +            SDL_XBIOS_AddMode(_this, 320, 240, 8, TT_LOW, SDL_TRUE);
   3.128 +        }
   3.129 +        break;
   3.130 +    case VDO_F30:
   3.131 +        {
   3.132 +	    Uint16 modecodemask = VsetMode(-1) & (VGA | PAL);
   3.133 +            int i;
   3.134 +
   3.135 +            switch (VgetMonitor()) {
   3.136 +            case MONITOR_MONO:
   3.137 +                /* Not usable */
   3.138 +                break;
   3.139 +            case MONITOR_RGB:
   3.140 +            case MONITOR_TV:
   3.141 +               for (i=0; i<sizeof(falcon_rgb_modes)/sizeof(xbios_mode_t); i++) {
   3.142 +                   SDL_XBIOS_AddMode(_this, falcon_rgb_modes[i].width,
   3.143 +		       falcon_rgb_modes[i].height, falcon_rgb_modes[i].bpp,
   3.144 +		       falcon_rgb_modes[i].modecode & modecodemask, SDL_FALSE);
   3.145 +	       }
   3.146 +               break;
   3.147 +            case MONITOR_VGA:
   3.148 +               for (i=0; i<sizeof(falcon_vga_modes)/sizeof(xbios_mode_t); i++) {
   3.149 +                   SDL_XBIOS_AddMode(_this, falcon_vga_modes[i].width,
   3.150 +		       falcon_vga_modes[i].height, falcon_vga_modes[i].bpp,
   3.151 +		       falcon_vga_modes[i].modecode & modecodemask, SDL_FALSE);
   3.152 +	       }
   3.153 +               break;
   3.154 +            }
   3.155 +        }
   3.156 +        break;
   3.157 +    }
   3.158 +}
   3.159 +
   3.160 +void
   3.161 +SDL_XBIOS_GetDisplayModes(_THIS)
   3.162 +{
   3.163 +    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   3.164 +    SDL_DisplayMode mode;
   3.165 +    //SDL_AddDisplayMode(_this->current_display, &mode);
   3.166 +}
   3.167 +
   3.168 +int
   3.169 +SDL_XBIOS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   3.170 +{
   3.171 +    //SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
   3.172 +    return -1;
   3.173 +}
   3.174 +
   3.175 +void
   3.176 +SDL_XBIOS_QuitModes(_THIS)
   3.177 +{
   3.178 +}
   3.179 +
   3.180 +/* vi: set ts=4 sw=4 expandtab: */