src/video/xbios/SDL_xbios.c
author Patrice Mandin <patmandin@gmail.com>
Wed, 17 Nov 2004 23:23:03 +0000
changeset 979 c9d1ade1fb0b
parent 978 3b1ba22f5a28
child 980 7d6f8804a293
permissions -rw-r--r--
Grr, have to resort video modes one more time
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 735
diff changeset
     3
    Copyright (C) 1997-2004 Sam Lantinga
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Library General Public
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2 of the License, or (at your option) any later version.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Library General Public License for more details.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Library General Public
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#ifdef SAVE_RCSID
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
static char rcsid =
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
 "@(#) $Id$";
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
/*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
 * Xbios SDL video driver
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
 * 
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
 * Patrice Mandin
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include <stdio.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#include <stdlib.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#include <string.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#include <sys/stat.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#include <unistd.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    40
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    41
#include <GL/osmesa.h>
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    42
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    43
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
/* Mint includes */
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 508
diff changeset
    45
#include <mint/cookie.h>
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
#include <mint/osbind.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
#include <mint/falcon.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
#include "SDL.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
#include "SDL_error.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
#include "SDL_video.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
#include "SDL_mouse.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
#include "SDL_sysvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
#include "SDL_pixels_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
#include "SDL_events_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
#include "SDL_ataric2p_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
#include "SDL_atarievents_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
#include "SDL_atarimxalloc_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
#include "SDL_xbios.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
#define XBIOS_VID_DRIVER_NAME "xbios"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
    64
/*#define DEBUG_VIDEO_XBIOS 1*/
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
    65
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
/* Initialization/Query functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
static void XBIOS_VideoQuit(_THIS);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
/* Hardware surface functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    81
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    82
/* OpenGL functions */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    83
static int XBIOS_GL_LoadLibrary(_THIS, const char *path);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    84
static void *XBIOS_GL_GetProcAddress(_THIS, const char *proc);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    85
static int XBIOS_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    86
static int XBIOS_GL_MakeCurrent(_THIS);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    87
static void XBIOS_GL_SwapBuffers(_THIS);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    88
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
    89
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
/* List of video modes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
/* ST modes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
static int xbiosnummodes_st=1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
static xbiosmode_t xbiosmodelist_st[]={
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
	{ST_LOW>>8,320,200,4,SDL_FALSE}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
/* TT modes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
static int xbiosnummodes_tt=2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
static xbiosmode_t xbiosmodelist_tt[]={
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
	{TT_LOW,320,480,8,SDL_FALSE},
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
	{TT_LOW,320,240,8,SDL_TRUE}	/* Software double-lined mode */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
/* Falcon RVB modes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
static int xbiosnummodes_f30rvb=16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
static xbiosmode_t xbiosmodelist_f30rvb[]={
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
	{BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE},
979
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   109
	{BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE},
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   110
	{BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE},
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   111
	{BPS16|COL80,640,200,16,SDL_FALSE},
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   112
	{BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE},
979
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   113
	{BPS16|OVERSCAN,384,240,16,SDL_FALSE},
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   114
	{BPS16|VERTFLAG,320,400,16,SDL_FALSE},
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
	{BPS16,320,200,16,SDL_FALSE},
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
	{BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE},
979
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   118
	{BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE},
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   119
	{BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE},
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   120
	{BPS8|COL80,640,200,8,SDL_FALSE},
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   121
	{BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE},
979
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   122
	{BPS8|OVERSCAN,384,240,8,SDL_FALSE},
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   123
	{BPS8|VERTFLAG,320,400,8,SDL_FALSE},
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
	{BPS8,320,200,8,SDL_FALSE}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
/* Falcon VGA modes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
static int xbiosnummodes_f30vga=6;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
static xbiosmode_t xbiosmodelist_f30vga[]={
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
	{BPS16,320,480,16,SDL_FALSE},
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
	{BPS16|VERTFLAG,320,240,16,SDL_FALSE},
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
	{BPS8|COL80,640,480,8,SDL_FALSE},	
979
c9d1ade1fb0b Grr, have to resort video modes one more time
Patrice Mandin <patmandin@gmail.com>
parents: 978
diff changeset
   134
	{BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE},
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   135
	{BPS8,320,480,8,SDL_FALSE},
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
	{BPS8|VERTFLAG,320,240,8,SDL_FALSE}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
/* To setup palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
static unsigned short	TT_palette[256];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
static unsigned long	F30_palette[256];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
/* Xbios driver bootstrap functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
static int XBIOS_Available(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
{
797
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   148
	unsigned long cookie_vdo, cookie_mil, cookie_hade;
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   149
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   150
	/* Milan/Hades Atari clones do not have an Atari video chip */
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   151
	if ( (Getcookie(C__MIL, &cookie_mil) == C_FOUND) ||
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   152
		(Getcookie(C_hade, &cookie_hade) == C_FOUND) ) {
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   153
		return 0;
d0f1e34290d6 Milan and Hades Atari clones do not have an Atari video chip
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   154
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
	/* Cookie _VDO present ? if not, assume ST machine */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
	if (Getcookie(C__VDO, &cookie_vdo) != C_FOUND) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
		cookie_vdo = VDO_ST << 16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
	/* Test if we have a monochrome monitor plugged in */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
	switch( cookie_vdo >>16) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
		case VDO_ST:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
		case VDO_STE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
			if ( Getrez() == (ST_HIGH>>8) )
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
				return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
		case VDO_TT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
			if ( (EgetShift() & ES_MODE) == TT_HIGH)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
				return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
		case VDO_F30:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
			if ( Montype() == MONITOR_MONO)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
				return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
		default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
			return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
	return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
static void XBIOS_DeleteDevice(SDL_VideoDevice *device)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
	free(device->hidden);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
	free(device);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
static SDL_VideoDevice *XBIOS_CreateDevice(int devindex)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
	SDL_VideoDevice *device;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
	/* Initialize all variables that we clean on shutdown */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
	if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
		memset(device, 0, (sizeof *device));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
		device->hidden = (struct SDL_PrivateVideoData *)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
				malloc((sizeof *device->hidden));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
	if ( (device == NULL) || (device->hidden == NULL) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
		SDL_OutOfMemory();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
		if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
			free(device);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
		return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
	memset(device->hidden, 0, (sizeof *device->hidden));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
	/* Video functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
	device->VideoInit = XBIOS_VideoInit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
	device->ListModes = XBIOS_ListModes;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
	device->SetVideoMode = XBIOS_SetVideoMode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
	device->SetColors = XBIOS_SetColors;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
	device->UpdateRects = NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
	device->VideoQuit = XBIOS_VideoQuit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
	device->AllocHWSurface = XBIOS_AllocHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
	device->LockHWSurface = XBIOS_LockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
	device->UnlockHWSurface = XBIOS_UnlockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
	device->FlipHWSurface = XBIOS_FlipHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
	device->FreeHWSurface = XBIOS_FreeHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   222
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   223
	/* OpenGL functions */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   224
	device->GL_LoadLibrary = XBIOS_GL_LoadLibrary;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   225
	device->GL_GetProcAddress = XBIOS_GL_GetProcAddress;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   226
	device->GL_GetAttribute = XBIOS_GL_GetAttribute;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   227
	device->GL_MakeCurrent = XBIOS_GL_MakeCurrent;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   228
	device->GL_SwapBuffers = XBIOS_GL_SwapBuffers;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   229
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   230
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
	/* Events */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
	device->InitOSKeymap = Atari_InitOSKeymap;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
	device->PumpEvents = Atari_PumpEvents;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
	device->free = XBIOS_DeleteDevice;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
	return device;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
VideoBootStrap XBIOS_bootstrap = {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
	XBIOS_VID_DRIVER_NAME, "Atari Xbios driver",
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
	XBIOS_Available, XBIOS_CreateDevice
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
	int i,j8,j16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
	xbiosmode_t *current_mode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
	/* Initialize all variables that we clean on shutdown */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
	memset (SDL_modelist, 0, sizeof(SDL_modelist));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
	/* Cookie _VDO present ? if not, assume ST machine */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
	if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
		XBIOS_cvdo = VDO_ST << 16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
	/* Allocate memory for old palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
	XBIOS_oldpalette = (void *)malloc(256*sizeof(long));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
	if ( !XBIOS_oldpalette ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
		SDL_SetError("Unable to allocate memory for old palette\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
		return(-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
	/* Initialize video mode list */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
	/* and save current screen status (palette, screen address, video mode) */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
	switch (XBIOS_cvdo >>16) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
		case VDO_ST:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
		case VDO_STE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
				short *oldpalette;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
				XBIOS_nummodes=xbiosnummodes_st;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
				XBIOS_modelist=xbiosmodelist_st;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
			
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
				XBIOS_oldvbase=Physbase();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
				XBIOS_oldvmode=Getrez();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
				switch(XBIOS_oldvmode << 8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
					case ST_LOW:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
						XBIOS_oldnumcol=16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
						break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
					case ST_MED:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
						XBIOS_oldnumcol=4;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
						break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
					case ST_HIGH:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
						XBIOS_oldnumcol=2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
						break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
					default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
						XBIOS_oldnumcol=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
						break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
				}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
				oldpalette= (short *) XBIOS_oldpalette;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
				for (i=0;i<XBIOS_oldnumcol;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
					*oldpalette++=Setcolor(i,-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
				}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
				vformat->BitsPerPixel = 8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
		case VDO_TT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
			XBIOS_nummodes=xbiosnummodes_tt;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
			XBIOS_modelist=xbiosmodelist_tt;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
			XBIOS_oldvbase=Logbase();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
			XBIOS_oldvmode=EgetShift();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
			switch(XBIOS_oldvmode & ES_MODE) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
				case TT_LOW:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
					XBIOS_oldnumcol=256;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
				case ST_LOW:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
				case TT_MED:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
					XBIOS_oldnumcol=16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
				case ST_MED:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
					XBIOS_oldnumcol=4;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
				case ST_HIGH:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
				case TT_HIGH:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
					XBIOS_oldnumcol=2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
				default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
					XBIOS_oldnumcol=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
			if (XBIOS_oldnumcol) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
				EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
			vformat->BitsPerPixel = 8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
		case VDO_F30:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
			switch (Montype())
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
				case MONITOR_MONO:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
					/* Not usable */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
				case MONITOR_RGB:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
				case MONITOR_TV:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
					XBIOS_nummodes = xbiosnummodes_f30rvb;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
					XBIOS_modelist = xbiosmodelist_f30rvb;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
				case MONITOR_VGA:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
					XBIOS_nummodes = xbiosnummodes_f30vga;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
					XBIOS_modelist = xbiosmodelist_f30vga;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
					break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
			XBIOS_oldvbase=Logbase();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
			XBIOS_oldvmode=Vsetmode(-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
			XBIOS_oldnumcol= 1<< (1 << (XBIOS_oldvmode & NUMCOLS));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
			if (XBIOS_oldnumcol > 256) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
				XBIOS_oldnumcol = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
			if (XBIOS_oldnumcol) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
				VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
			vformat->BitsPerPixel = 16;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
			/* Keep vga/rvb, and pal/ntsc bits */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
			current_mode = XBIOS_modelist;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
			for (i=0;i<XBIOS_nummodes;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
				Uint16 newvmode;			
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
				newvmode = current_mode->number;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
				newvmode &= ~(VGA|PAL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
				newvmode |= XBIOS_oldvmode & (VGA|PAL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
				current_mode->number = newvmode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
				
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
				current_mode++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
	current_mode = XBIOS_modelist;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
	j8 = j16 = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
	for (i=0;i<XBIOS_nummodes;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
		switch (current_mode->depth) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
			case 4:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
			case 8:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
				SDL_modelist[0][j8] = malloc(sizeof(SDL_Rect));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
				SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
				SDL_modelist[0][j8]->w = current_mode->width;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
				SDL_modelist[0][j8]->h = current_mode->height;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
				XBIOS_videomodes[0][j8]=current_mode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
				current_mode++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
				j8++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
				break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
			case 16:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
				SDL_modelist[1][j16] = malloc(sizeof(SDL_Rect));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
				SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
				SDL_modelist[1][j16]->w = current_mode->width;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
				SDL_modelist[1][j16]->h = current_mode->height;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
				XBIOS_videomodes[1][j16]=current_mode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
				current_mode++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
				j16++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
				break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
		}		
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
	SDL_modelist[0][j8] = NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
	SDL_modelist[1][j16] = NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
	XBIOS_screens[0]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
	XBIOS_screens[1]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
	XBIOS_shadowscreen=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
	/* Update hardware info */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
	this->info.hw_available = 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
	this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
	/* Init chunky to planar routine */
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   416
	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   418
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   419
	this->gl_config.driver_loaded = 1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   420
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   421
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
	/* We're done! */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   425
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   426
static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
	/* 8 bits -> list 0 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
	/* 16 bits -> list 1 */
712
8be92df64b22 Finally bugfixed: the simpler the better
Patrice Mandin <patmandin@gmail.com>
parents: 711
diff changeset
   430
	if ((format->BitsPerPixel != 8) && (format->BitsPerPixel !=16)) {
711
8db4098e944b Severe bugfix: format->BitsPerPixel not checked in ListModes function
Patrice Mandin <patmandin@gmail.com>
parents: 598
diff changeset
   431
		return NULL;
8db4098e944b Severe bugfix: format->BitsPerPixel not checked in ListModes function
Patrice Mandin <patmandin@gmail.com>
parents: 598
diff changeset
   432
	}
8db4098e944b Severe bugfix: format->BitsPerPixel not checked in ListModes function
Patrice Mandin <patmandin@gmail.com>
parents: 598
diff changeset
   433
712
8be92df64b22 Finally bugfixed: the simpler the better
Patrice Mandin <patmandin@gmail.com>
parents: 711
diff changeset
   434
	return(SDL_modelist[(format->BitsPerPixel)>>4]);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
static void XBIOS_FreeBuffers(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   438
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   439
	int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   441
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   442
	/* Shutdown OpenGL context */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   443
	if (XBIOS_ctx) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   444
		OSMesaDestroyContext(XBIOS_ctx);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   445
		XBIOS_ctx = NULL;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   446
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   447
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   448
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
	for (i=0;i<2;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
		if (XBIOS_screensmem[i]!=NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
			Mfree(XBIOS_screensmem[i]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
			XBIOS_screensmem[i]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
	if (XBIOS_shadowscreen!=NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
		Mfree(XBIOS_shadowscreen);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   458
		XBIOS_shadowscreen=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   459
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   460
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   461
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   462
static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   463
				int width, int height, int bpp, Uint32 flags)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   464
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
	int mode, new_depth;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
	int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   467
	xbiosmode_t *new_video_mode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
	Uint32 new_screen_size;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
	Uint32 modeflags;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
	/* Free current buffers */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   472
	XBIOS_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
801
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   474
	/* Limit bpp */
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   475
	if (bpp>16) {
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   476
		bpp = 16;
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   477
	}
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   478
	bpp >>= 4;
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   479
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
	/* Search if the mode exists (width, height, bpp) */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
	for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
		if ( (SDL_modelist[bpp][mode]->w == width) &&
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
		     (SDL_modelist[bpp][mode]->h == height) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   485
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   486
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   487
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
	if ( SDL_modelist[bpp][mode] == NULL ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
		SDL_SetError("Couldn't find requested mode in list");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
		return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   491
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
508
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   493
	modeflags = SDL_FULLSCREEN;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
	/* Allocate needed buffers: simple/double buffer and shadow surface */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
	new_video_mode = XBIOS_videomodes[bpp][mode];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
	new_depth = new_video_mode->depth;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   498
	if (new_depth == 4) {
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   499
		SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   500
		new_depth=8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   501
		modeflags |= SDL_SWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   502
	} else if (new_depth == 8) {
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   503
		SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
508
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   504
		modeflags |= SDL_SWSURFACE|SDL_HWPALETTE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   505
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
		modeflags |= SDL_HWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
	new_screen_size = width * height * ((new_depth)>>3);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
	new_screen_size += 256; /* To align on a 256 byte adress */	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
	if (new_depth == 8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
		XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
		if (XBIOS_shadowscreen == NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
			SDL_SetError("XBIOS_SetVideoMode: Not enough memory for shadow surface");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
			return (NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
		}
287
e4bd0cf95506 From: Patrice Mandin <pmandin@caramail.com>
Sam Lantinga <slouken@libsdl.org>
parents: 281
diff changeset
   519
		memset(XBIOS_shadowscreen, 0, new_screen_size);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   520
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   521
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   522
	/* Output buffer needs to be twice in size for the software double-line mode */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   523
	XBIOS_doubleline = SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
	if (new_video_mode->doubleline) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   525
		new_screen_size <<= 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   526
		XBIOS_doubleline = SDL_TRUE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   527
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   528
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   529
	XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   530
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   531
	if (XBIOS_screensmem[0]==NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   532
		XBIOS_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
		SDL_SetError("XBIOS_SetVideoMode: Not enough memory for video buffer");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
		return (NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
	}
287
e4bd0cf95506 From: Patrice Mandin <pmandin@caramail.com>
Sam Lantinga <slouken@libsdl.org>
parents: 281
diff changeset
   536
	memset(XBIOS_screensmem[0], 0, new_screen_size);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   538
	XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   539
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   540
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   541
	if (flags & SDL_OPENGL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   542
		if (this->gl_config.double_buffer) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   543
			flags |= SDL_DOUBLEBUF;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   544
		}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   545
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   546
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   547
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   548
	/* Double buffer ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   549
	if (flags & SDL_DOUBLEBUF) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   550
		XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   551
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   552
		if (XBIOS_screensmem[1]==NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   553
			XBIOS_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   554
			SDL_SetError("XBIOS_SetVideoMode: Not enough memory for double buffer");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   555
			return (NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   556
		}
287
e4bd0cf95506 From: Patrice Mandin <pmandin@caramail.com>
Sam Lantinga <slouken@libsdl.org>
parents: 281
diff changeset
   557
		memset(XBIOS_screensmem[1], 0, new_screen_size);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
		XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
		modeflags |= SDL_DOUBLEBUF;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
	/* Allocate the new pixel format for the screen */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
	if ( ! SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
		XBIOS_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   566
		SDL_SetError("Couldn't allocate new pixel format for requested mode");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
		return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   569
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   570
	current->w = XBIOS_width = width;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   571
	current->h = XBIOS_height = height;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   572
	current->pitch = (width * new_depth)>>3;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   573
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   574
	/* this is for C2P conversion */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   575
	XBIOS_pitch = (new_video_mode->width * new_video_mode->depth)>>3;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   576
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   577
	if (new_depth == 8)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   578
		current->pixels = XBIOS_shadowscreen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   579
	else
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   580
		current->pixels = XBIOS_screens[0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   581
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   582
	XBIOS_fbnum = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   583
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   584
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   585
	if (flags & SDL_OPENGL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   586
		GLenum format;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   587
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   588
		/* Init OpenGL context using OSMesa */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   589
		if (new_depth == 8) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   590
			format = OSMESA_COLOR_INDEX;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   591
		} else {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   592
			format = OSMESA_RGB_565;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   593
		}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   594
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   595
		XBIOS_ctx = OSMesaCreateContextExt( format, this->gl_config.depth_size,
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   596
			this->gl_config.stencil_size, this->gl_config.accum_red_size +
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   597
			this->gl_config.accum_green_size + this->gl_config.accum_blue_size +
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   598
			this->gl_config.accum_alpha_size, NULL );
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   599
		if (!XBIOS_ctx) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   600
			XBIOS_FreeBuffers(this);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   601
			SDL_SetError("OSMesaCreateContext failed");
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   602
			return(NULL);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   603
		}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   604
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   605
		modeflags |= SDL_OPENGL;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   606
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   607
#endif
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   608
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   609
	current->flags = modeflags;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   610
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   611
	/* Now set the video mode */
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   612
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   613
	Setscreen(-1,XBIOS_screens[0],-1);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   614
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   615
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   616
	switch(XBIOS_cvdo >> 16) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   617
		case VDO_ST:
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   618
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   619
			Setscreen(-1,-1,new_video_mode->number);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   620
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
			/* Reset palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
			for (i=0;i<16;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
				int c;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   625
				c = ((i>>1)<<8) | ((i>>1)<<4) | (i>>1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
				if ((i & 1) && (i<15))
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
					c += (1<<4);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   628
				if (i==14)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
					c -= 1<<8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   631
				TT_palette[i]= c;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   632
			}
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   633
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   634
			Setpalette(TT_palette);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   635
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   636
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   637
		case VDO_STE:
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   638
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   639
			Setscreen(-1,-1,new_video_mode->number);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   640
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
			/* Reset palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   642
			for (i=0;i<16;i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   643
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   644
				int c;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   646
				c=((i&1)<<3)|((i>>1)&7);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   647
				TT_palette[i]=(c<<8)|(c<<4)|c;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   648
			}
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   649
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   650
			Setpalette(TT_palette);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   651
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   652
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
		case VDO_TT:
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   654
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   655
			EsetShift(new_video_mode->number);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   656
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
		case VDO_F30:
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   659
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
			Vsetmode(new_video_mode->number);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   661
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   663
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   664
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   665
	Vsync();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   666
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   667
	this->UpdateRects = XBIOS_UpdateRects;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   668
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   669
	return (current);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   670
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   671
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   672
/* We don't actually allow hardware surfaces other than the main one */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   673
static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   674
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   675
	return(-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   676
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   677
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   678
static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   680
	return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   681
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   682
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   683
static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   684
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   686
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   688
static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   689
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   690
	return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   691
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
	SDL_Surface *surface;
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   696
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   697
	surface = this->screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   698
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   699
	if ((surface->format->BitsPerPixel) == 8) {
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   700
		void *destscr;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   701
		int destx;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   702
		int i;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   703
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   704
		/* Center on destination screen */
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   705
		destscr = XBIOS_screens[XBIOS_fbnum];
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   706
		destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   707
		destx = (XBIOS_width - surface->w) >> 1;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   708
		destx &= ~15;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   709
		destscr += destx;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   710
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   711
		for (i=0;i<numrects;i++) {
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   712
			void *source,*destination;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   713
			int x1,x2;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   714
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   715
			x1 = rects[i].x & ~15;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 314
diff changeset
   716
			x2 = rects[i].x+rects[i].w;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 314
diff changeset
   717
			if (x2 & 15) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 314
diff changeset
   718
				x2 = (x2 | 15) +1;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 314
diff changeset
   719
			}
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   720
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   721
			source = surface->pixels;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   722
			source += surface->pitch * rects[i].y;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   723
			source += x1;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   724
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   725
			destination = destscr;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   726
			destination += XBIOS_pitch * rects[i].y;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   727
			destination += x1;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   728
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   729
			/* Convert chunky to planar screen */
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   730
			SDL_Atari_C2pConvert(
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   731
				source,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   732
				destination,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   733
				x2-x1,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   734
				rects[i].h,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   735
				XBIOS_doubleline,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   736
				surface->pitch,
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   737
				XBIOS_pitch
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   738
			);
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   739
		}
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   740
	}
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   741
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   742
#ifndef DEBUG_VIDEO_XBIOS
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   743
	Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   744
#endif
314
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   745
	Vsync();
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   746
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   747
	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   748
		XBIOS_fbnum ^= 1;
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   749
		if ((surface->format->BitsPerPixel) > 8) {
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   750
			surface->pixels=XBIOS_screens[XBIOS_fbnum];
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   751
		}
bff64eba7721 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 311
diff changeset
   752
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   753
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   754
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   755
static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   756
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   757
	if ((surface->format->BitsPerPixel) == 8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   758
		void *destscr;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   759
		int destx;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   760
			
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   761
		/* Center on destination screen */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   762
		destscr = XBIOS_screens[XBIOS_fbnum];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   763
		destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   764
		destx = (XBIOS_width - surface->w) >> 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   765
		destx &= ~15;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   766
		destscr += destx;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   767
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   768
		/* Convert chunky to planar screen */
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   769
		SDL_Atari_C2pConvert(
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   770
			surface->pixels,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   771
			destscr,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   772
			surface->w,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   773
			surface->h,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   774
			XBIOS_doubleline,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   775
			surface->pitch,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   776
			XBIOS_pitch
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   777
		);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   778
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   779
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   780
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   781
	Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   782
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   783
	Vsync();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   784
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   785
	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
311
2847fd83f115 Date: Fri, 15 Mar 2002 18:24:59 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   786
		XBIOS_fbnum ^= 1;
2847fd83f115 Date: Fri, 15 Mar 2002 18:24:59 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   787
		if ((surface->format->BitsPerPixel) > 8) {
2847fd83f115 Date: Fri, 15 Mar 2002 18:24:59 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   788
			surface->pixels=XBIOS_screens[XBIOS_fbnum];
2847fd83f115 Date: Fri, 15 Mar 2002 18:24:59 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   789
		}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   790
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   791
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   792
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   793
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   794
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   795
static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   796
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   797
	int		i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   798
	int		r,v,b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   799
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   800
	switch( XBIOS_cvdo >> 16) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   801
		case VDO_ST:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   802
		case VDO_STE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   803
		 	for (i=0;i<ncolors;i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   804
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   805
				r = colors[i].r;	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   806
				v = colors[i].g;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   807
				b = colors[i].b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   808
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   809
				TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   810
			}
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   811
			SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   812
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   813
		case VDO_TT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   814
			for(i = 0; i < ncolors; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   815
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   816
				r = colors[i].r;	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   817
				v = colors[i].g;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   818
				b = colors[i].b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   819
					
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   820
				TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   821
			}
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   822
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   823
			EsetPalette(firstcolor,ncolors,TT_palette);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   824
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   825
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   826
		case VDO_F30:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   827
			for(i = 0; i < ncolors; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   828
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   829
				r = colors[i].r;	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   830
				v = colors[i].g;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   831
				b = colors[i].b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   832
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   833
				F30_palette[i]=(r<<16)|(v<<8)|b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   834
			}
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   835
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   836
			VsetRGB(firstcolor,ncolors,F30_palette);
735
abec2a842d11 Use new C2P routine
Patrice Mandin <patmandin@gmail.com>
parents: 712
diff changeset
   837
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   838
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   839
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   840
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   841
	return(1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   842
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   843
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   844
/* Note:  If we are terminated, this could be called in the middle of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   845
   another SDL video routine -- notably UpdateRects.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   846
*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   847
static void XBIOS_VideoQuit(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   848
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   849
	int i,j;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   850
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   851
	Atari_ShutdownEvents();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   852
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   853
	/* Restore video mode and palette */
801
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   854
#ifndef DEBUG_VIDEO_XBIOS
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   855
	switch(XBIOS_cvdo >> 16) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   856
		case VDO_ST:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   857
		case VDO_STE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   858
			Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   859
			if (XBIOS_oldnumcol) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   860
				Setpalette(XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   861
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   862
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   863
		case VDO_TT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   864
			Setscreen(-1,XBIOS_oldvbase,-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   865
			EsetShift(XBIOS_oldvmode);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   866
			if (XBIOS_oldnumcol) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   867
				EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   868
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   869
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   870
		case VDO_F30:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   871
			Setscreen(-1, XBIOS_oldvbase, -1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   872
			Vsetmode(XBIOS_oldvmode);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   873
			if (XBIOS_oldnumcol) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   874
				VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   875
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   876
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   877
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   878
	Vsync();
801
ff1058d642dc Video modes must be sorted by Y size, for SDL_GetVideoMode() to operate properly
Patrice Mandin <patmandin@gmail.com>
parents: 797
diff changeset
   879
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   880
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   881
	if (XBIOS_oldpalette) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   882
		free(XBIOS_oldpalette);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   883
		XBIOS_oldpalette=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   884
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   885
	XBIOS_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   886
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   887
	/* Free mode list */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   888
	for (j=0;j<NUM_MODELISTS;j++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   889
		for (i=0;i<SDL_NUMMODES;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   890
			if (SDL_modelist[j][i]!=NULL) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   891
				free(SDL_modelist[j][i]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   892
				SDL_modelist[j][i]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   893
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   894
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   895
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   896
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   897
	this->screen->pixels = NULL;	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   898
}
978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   899
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   900
#ifdef HAVE_OPENGL
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   901
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   902
/* OpenGL functions */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   903
static int XBIOS_GL_LoadLibrary(_THIS, const char *path)
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   904
{
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   905
	/* Library is always opened */
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   906
	this->gl_config.driver_loaded = 1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   907
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   908
	return 0;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   909
}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   910
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   911
static void *XBIOS_GL_GetProcAddress(_THIS, const char *proc)
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   912
{
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   913
	void *func = NULL;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   914
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   915
	if (XBIOS_ctx != NULL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   916
		func = OSMesaGetProcAddress(proc);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   917
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   918
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   919
	return func;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   920
}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   921
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   922
static int XBIOS_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   923
{
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   924
	GLenum mesa_attrib;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   925
	SDL_Surface *surface;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   926
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   927
	if (XBIOS_ctx == NULL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   928
		return -1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   929
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   930
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   931
	switch(attrib) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   932
		case SDL_GL_RED_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   933
			mesa_attrib = GL_RED_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   934
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   935
		case SDL_GL_GREEN_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   936
			mesa_attrib = GL_GREEN_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   937
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   938
		case SDL_GL_BLUE_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   939
			mesa_attrib = GL_BLUE_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   940
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   941
		case SDL_GL_ALPHA_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   942
			mesa_attrib = GL_ALPHA_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   943
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   944
		case SDL_GL_DOUBLEBUFFER:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   945
			surface = this->screen;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   946
			*value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   947
			return 0;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   948
		case SDL_GL_DEPTH_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   949
			mesa_attrib = GL_DEPTH_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   950
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   951
		case SDL_GL_STENCIL_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   952
			mesa_attrib = GL_STENCIL_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   953
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   954
		case SDL_GL_ACCUM_RED_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   955
			mesa_attrib = GL_ACCUM_RED_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   956
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   957
		case SDL_GL_ACCUM_GREEN_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   958
			mesa_attrib = GL_ACCUM_GREEN_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   959
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   960
		case SDL_GL_ACCUM_BLUE_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   961
			mesa_attrib = GL_ACCUM_BLUE_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   962
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   963
		case SDL_GL_ACCUM_ALPHA_SIZE:
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   964
			mesa_attrib = GL_ACCUM_ALPHA_BITS;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   965
			break;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   966
		default :
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   967
			return -1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   968
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   969
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   970
	glGetIntegerv(mesa_attrib, value);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   971
	return 0;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   972
}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   973
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   974
static int XBIOS_GL_MakeCurrent(_THIS)
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   975
{
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   976
	SDL_Surface *surface;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   977
	GLenum type;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   978
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   979
	if (XBIOS_ctx == NULL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   980
		return -1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   981
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   982
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   983
	surface = this->screen;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   984
	if ((surface->format->BitsPerPixel) == 8) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   985
		type = GL_UNSIGNED_BYTE;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   986
	} else {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   987
		type = GL_UNSIGNED_SHORT_5_6_5;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   988
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   989
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   990
	if (!OSMesaMakeCurrent(XBIOS_ctx, surface->pixels, type, surface->w, surface->h)) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   991
		SDL_SetError("Can not make OpenGL context current");
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   992
		return -1;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   993
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   994
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   995
	return 0;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   996
}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   997
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   998
static void XBIOS_GL_SwapBuffers(_THIS)
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
   999
{
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1000
	if (XBIOS_ctx == NULL) {
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1001
		return;
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1002
	}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1003
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1004
	XBIOS_FlipHWSurface(this, this->screen);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1005
	XBIOS_GL_MakeCurrent(this);
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1006
}
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1007
3b1ba22f5a28 Add support for OpenGL on Atari using OSMesa, the offscreen rendering driver from Mesa
Patrice Mandin <patmandin@gmail.com>
parents: 972
diff changeset
  1008
#endif