src/video/gem/SDL_gemvideo.c
author Patrice Mandin <patmandin@gmail.com>
Fri, 06 Feb 2004 22:41:00 +0000
changeset 799 85960507bd2e
parent 769 b8d311d90021
child 800 60a4293ffea9
permissions -rw-r--r--
Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
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: 737
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
/*
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    29
	GEM video driver
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    30
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    31
	Patrice Mandin
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    32
	and work from
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    33
	Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    34
*/
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#include <stdio.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#include <stdlib.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#include <string.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
/* Mint includes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
#include <gem.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
#include <gemx.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
#include <mint/osbind.h>
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 508
diff changeset
    44
#include <mint/cookie.h>
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
#include "SDL.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
#include "SDL_error.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
#include "SDL_video.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
#include "SDL_mouse.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
#include "SDL_sysvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
#include "SDL_pixels_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
#include "SDL_events_c.h"
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
    53
#include "SDL_cursor_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
#include "SDL_ataric2p_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
#include "SDL_atarieddi_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
#include "SDL_atarimxalloc_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
#include "SDL_gemvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
#include "SDL_gemevents_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
#include "SDL_gemmouse_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
#include "SDL_gemwm_c.h"
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
    62
#include "SDL_xbiosevents_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
/* Defines */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
    66
#define DEBUG_VIDEO_GEM	0
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
    67
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
#define GEM_VID_DRIVER_NAME "gem"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
    70
#undef MIN
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
    71
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
    72
#undef MAX
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
    73
#define MAX(a,b) (((a)>(b)) ? (a) : (b))
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
    74
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
/* Variables */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
static unsigned char vdi_index[256] = {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
	0,  2,  3,  6,  4,  7,  5,   8,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
	9, 10, 11, 14, 12, 15, 13, 255
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
};
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
static const unsigned char empty_name[]="";
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
/* Initialization/Query functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
static int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
static SDL_Surface *GEM_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
    88
static int GEM_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
    89
static void GEM_VideoQuit(_THIS);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
/* Hardware surface functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
static int GEM_LockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
#if 0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
static int GEM_ToggleFullScreen(_THIS, int on);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
#endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
/* Internal functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
static void GEM_FreeBuffers(_THIS);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   104
static void GEM_ClearScreen(_THIS);
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   105
static void GEM_ClearRect(_THIS, short *rect);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   106
static void GEM_LockScreen(_THIS);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   107
static void GEM_UnlockScreen(_THIS);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
static void refresh_window(_THIS, int winhandle, short *rect);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
/* GEM driver bootstrap functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
static int GEM_Available(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
	/* Test if AES available */
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 508
diff changeset
   115
	if (appl_init() == -1)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
		return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
	appl_exit();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
	return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
static void GEM_DeleteDevice(SDL_VideoDevice *device)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
	free(device->hidden);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
	free(device);
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
static SDL_VideoDevice *GEM_CreateDevice(int devindex)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
	SDL_VideoDevice *device;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
	/* Initialize all variables that we clean on shutdown */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
	if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
		memset(device, 0, (sizeof *device));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
		device->hidden = (struct SDL_PrivateVideoData *)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
				malloc((sizeof *device->hidden));
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
	if ( (device == NULL) || (device->hidden == NULL) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
		SDL_OutOfMemory();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
		if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
			free(device);
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
		return(0);
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
	memset(device->hidden, 0, (sizeof *device->hidden));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
	/* Set the function pointers */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
	device->VideoInit = GEM_VideoInit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
	device->ListModes = GEM_ListModes;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
	device->SetVideoMode = GEM_SetVideoMode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
	device->SetColors = GEM_SetColors;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
	device->UpdateRects = NULL /*GEM_UpdateRects*/;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
	device->VideoQuit = GEM_VideoQuit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
	device->AllocHWSurface = GEM_AllocHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
	device->LockHWSurface = GEM_LockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
	device->UnlockHWSurface = GEM_UnlockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
	device->FlipHWSurface = GEM_FlipHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
	device->FreeHWSurface = GEM_FreeHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
	device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
	/* Window manager */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
	device->SetCaption = GEM_SetCaption;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   164
	device->SetIcon = GEM_SetIcon;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
	device->IconifyWindow = GEM_IconifyWindow;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
	device->GrabInput = GEM_GrabInput;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
	/* Events */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
	device->InitOSKeymap = GEM_InitOSKeymap;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
	device->PumpEvents = GEM_PumpEvents;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
	/* Mouse */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
	device->FreeWMCursor = GEM_FreeWMCursor;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
	device->CreateWMCursor = GEM_CreateWMCursor;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
	device->ShowWMCursor = GEM_ShowWMCursor;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   176
	device->WarpWMCursor = NULL /*GEM_WarpWMCursor*/;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
	device->CheckMouseMode = GEM_CheckMouseMode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   179
	/* Joystick + Mouse relative motion */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   180
	SDL_AtariXbios_InstallVectors(ATARI_XBIOS_MOUSEEVENTS|ATARI_XBIOS_JOYSTICKEVENTS);
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   181
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
	device->free = GEM_DeleteDevice;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
	return device;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
VideoBootStrap GEM_bootstrap = {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
	GEM_VID_DRIVER_NAME, "Atari GEM video driver",
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
	GEM_Available, GEM_CreateDevice
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
static void VDI_ReadExtInfo(_THIS, short *work_out)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
	unsigned long EdDI_version;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
	unsigned long cookie_EdDI;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
	Uint32 num_colours;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
	Uint16 clut_type, num_bits;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
	/* Read EdDI informations */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
	if  (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
		return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
	EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
	vq_scrninfo(VDI_handle, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
	VDI_format = work_out[0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
	clut_type = work_out[1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
	num_bits = work_out[2];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
	num_colours = *((Uint32 *) &work_out[3]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
	/* With EdDI>=1.1, we can have screen pitch, address and format
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
	 * so we can directly write to screen without using vro_cpyfm
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
	 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
	if (EdDI_version >= EDDI_11) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
		VDI_pitch = work_out[5];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
		VDI_screen = (void *) *((unsigned long *) &work_out[6]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   220
#if 0 /* lecoat */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
		switch(num_colours) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
			case 32768UL:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
				if (work_out[14] & (1<<7)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
					/* Little endian */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
					if (work_out[14] & (1<<1)) {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   226
						VDI_FBMASK(1<<13, 31<<3, (3<<14)|7, 31<<8);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
					} else {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   228
						VDI_FBMASK(1<<7, 31<<2, (7<<13)|3, 31<<8);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
					}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
				} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
					/* Big endian */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
					if (work_out[14] & (1<<1)) {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   233
						VDI_FBMASK(1<<5, 31<<11, 31<<6, 31);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
					} else {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   235
						VDI_FBMASK(1<<15, 31<<10, 31<<5, 31);
281
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
				}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
				break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
			case 65536UL:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
				if (work_out[14] & (1<<7)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
					/* Little endian */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   242
					VDI_FBMASK(0, 31<<3, (7<<13)|7, 31<<8);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
				} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
					/* Big endian */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   245
					VDI_FBMASK(0, 31<<11, 63<<5, 31);
281
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
				break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
			case 16777216UL:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
				if (work_out[14] & (1<<7)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
					/* Little endian */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
					switch(num_bits) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
						case 24:
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   253
							VDI_FBMASK(0, 255, 255<<8, 255<<16);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
							break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
						case 32:
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   256
							VDI_FBMASK(255, 255<<8, 255<<16, 255<<24);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
							break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
					}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
				} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
					/* Big endian */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
					switch(num_bits) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
						case 24:
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   263
							VDI_FBMASK(0, 255<<16, 255<<8, 255);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
							break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
						case 32:
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   266
							VDI_FBMASK(255<<24, 255<<16, 255<<8, 255);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
							break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
					}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
				}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
				break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
		}
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   272
#endif
281
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
	switch(clut_type) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
		case VDI_CLUT_HARDWARE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
			{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
				int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
				Uint16 *tmp_p;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
				tmp_p = (Uint16 *)&work_out[16];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
				for (i=0;i<256;i++) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   284
					vdi_index[*tmp_p++] = i;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
				}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
		case VDI_CLUT_SOFTWARE:
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   289
/* lecoat 			if (EdDI_version < EDDI_11) */ {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
				int component; /* red, green, blue, alpha, overlay */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
				int num_bit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
				unsigned short *tmp_p;
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
				/* We can build masks with info here */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
				tmp_p = (unsigned short *) &work_out[16];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
				for (component=0;component<5;component++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
					for (num_bit=0;num_bit<16;num_bit++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
						unsigned short valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
						valeur = *tmp_p++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
						if (valeur == 0xffff) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
							continue;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
						}
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
						switch(component) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
							case 0:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
								VDI_redmask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
								break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
							case 1:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
								VDI_greenmask |= 1<< valeur;
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 2:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
								VDI_bluemask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
								break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
							case 3:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
								VDI_alphamask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
								break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
						}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
					}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
				}
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   322
			}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   324
			/* Remove lower green bits for Intel endian screen */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   325
			if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   326
				VDI_greenmask &= ~(7<<13);
281
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
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
		case VDI_CLUT_NONE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
			break;
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
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
	int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
	short work_in[12], work_out[272], dummy;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
	/* Open AES (Application Environment Services) */
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 508
diff changeset
   340
	if (appl_init() == -1) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
		fprintf(stderr,"Can not open AES\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
		return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
	/* Read version and features */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   346
	GEM_version = aes_global[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   347
	if (GEM_version >= 0x0410) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   348
		short ap_gout[4], errorcode;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
		
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   350
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   351
		printf("sdl:video:gem: AES %02x.%02x\n", (GEM_version>>8) & 0xff, GEM_version & 0xff);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   352
#endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   353
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
		GEM_wfeatures=0;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   355
		errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   356
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   357
		printf("sdl:video:gem: appl_getinfo() returned 0x%04x\n", errorcode);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   358
#endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   359
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   360
		if (errorcode==0) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
			GEM_wfeatures=ap_gout[0];			
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   362
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   363
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   364
			printf("sdl:video:gem: AES wind_*() modes: 0x%04x\n", GEM_wfeatures);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   365
			printf("sdl:video:gem: AES window behaviours: 0x%04x\n", ap_gout[3]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   366
		} else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   367
			printf("sdl:video:gem: apgout[]={0x%04x,0x%04x,0x%04x,0x%04x}\n",
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   368
				ap_gout[0], ap_gout[1], ap_gout[1], ap_gout[3]
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   369
			);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   370
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
		}
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
	/* Ask VDI physical workstation handle opened by AES */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
	VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
	if (VDI_handle<1) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
		fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
		return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
	/* Open virtual VDI workstation */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
	work_in[0]=Getrez()+2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
	for(i = 1; i < 10; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
		work_in[i] = 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
	work_in[10] = 2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
	v_opnvwk(work_in, &VDI_handle, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
	if (VDI_handle == 0) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
		fprintf(stderr,"Can not open VDI virtual workstation\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
		return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
	/* Read fullscreen size */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
	VDI_w = work_out[0] + 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
	VDI_h = work_out[1] + 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
	/* Read desktop size and position */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
	if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
		fprintf(stderr,"Can not read desktop properties\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
		return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
	}
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
	/* Read bit depth */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
	vq_extnd(VDI_handle, 1, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
	VDI_bpp = work_out[4];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
	VDI_oldnumcolors=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
	switch(VDI_bpp) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
		case 8:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
			VDI_pixelsize=1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
		case 15:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
		case 16:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
			VDI_pixelsize=2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
		case 24:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
			VDI_pixelsize=3;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
		case 32:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
			VDI_pixelsize=4;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
			break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
		default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
			fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
			return 1;
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
	/* Setup hardware -> VDI palette mapping */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
	for(i = 16; i < 255; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
		vdi_index[i] = i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   431
	vdi_index[255] = 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
	/* Save current palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   434
	if (VDI_bpp>8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
		VDI_oldnumcolors=1<<8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
		VDI_oldnumcolors=1<<VDI_bpp;
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
	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
	for(i = 0; i < VDI_oldnumcolors; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
		short rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
		vq_color(VDI_handle, i, 0, rgb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
		VDI_oldpalette[i][0] = rgb[0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
		VDI_oldpalette[i][1] = rgb[1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   447
		VDI_oldpalette[i][2] = rgb[2];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   448
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
	/* Setup screen info */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
	GEM_title_name = empty_name;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
	GEM_icon_name = empty_name;
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
	GEM_handle = -1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
	GEM_locked = SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
	GEM_win_fulled = SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   458
	VDI_screen = NULL;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   459
#if 1 /* lecoat */
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   460
	VDI_pitch = VDI_w * VDI_pixelsize;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   461
	VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   462
	VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   463
	VDI_ReadExtInfo(this, work_out);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   464
#else
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
	VDI_ReadExtInfo(this, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
	if (VDI_screen == NULL) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   467
		VDI_pitch = VDI_w * VDI_pixelsize;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   468
		VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
		VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
	}
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   471
#endif
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   472
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   473
#ifdef DEBUG_VIDEO_GEM
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   474
	printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   475
	printf("sdl:video:gem: format=%d\n", VDI_format);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   476
	printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   477
		VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   478
	);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   479
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
	/* Setup destination mfdb */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
	VDI_dst_mfdb.fd_addr = NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
	/* Update hardware info */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   485
	this->info.hw_available = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   486
	this->info.video_mem = 0;
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
	/* Determine the screen depth */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
	/* we change this during the SDL_SetVideoMode implementation... */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
	vformat->BitsPerPixel = VDI_bpp;
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
	/* Set mouse cursor to arrow */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
	graf_mouse(ARROW, NULL);
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
	/* Init chunky to planar routine */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   496
	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   497
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   498
	/* Setup VDI fill functions */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   499
	vsf_color(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   500
	vsf_interior(VDI_handle,1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   501
	vsf_perimeter(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   502
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   503
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   504
	printf("sdl:video:gem: VideoInit(): done\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   505
#endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
	/* We're done! */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
	if (format->BitsPerPixel == VDI_bpp) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
		return((SDL_Rect **)-1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
		return ((SDL_Rect **)NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   519
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   520
static void GEM_FreeBuffers(_THIS)
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
	/* Release buffer */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   523
	if ( GEM_buffer2 ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   524
		free( GEM_buffer2 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   525
		GEM_buffer2=NULL;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   526
	}
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   527
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   528
	if ( GEM_buffer1 ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   529
		free( GEM_buffer1 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   530
		GEM_buffer1=NULL;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   531
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   532
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
	/* Destroy window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
	if (GEM_handle>=0) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
		wind_close(GEM_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   536
		wind_delete(GEM_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
		GEM_handle=-1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   538
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   539
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   540
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   541
static void GEM_ClearRect(_THIS, short *rect)
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   542
{
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   543
	short oldrgb[3], rgb[3]={0,0,0};
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   544
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   545
	vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   546
	vs_color(VDI_handle, vdi_index[0], rgb);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   547
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   548
	vsf_color(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   549
	vsf_interior(VDI_handle,1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   550
	vsf_perimeter(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   551
	v_bar(VDI_handle, rect);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   552
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   553
	vs_color(VDI_handle, vdi_index[0], oldrgb);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   554
}
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   555
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   556
static void GEM_ClearScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   557
{
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   558
	short pxy[4];
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   559
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   560
	v_hide_c(VDI_handle);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   561
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   562
	pxy[0] = pxy[1] = 0;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   563
	pxy[2] = VDI_w - 1;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   564
	pxy[3] = VDI_h - 1;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   565
	GEM_ClearRect(this, pxy);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   566
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   567
	v_show_c(VDI_handle, 1);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   568
}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   569
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   570
static void GEM_LockScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   571
{
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   572
	if (!GEM_locked) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   573
		/* Reserve memory space, used to be sure of compatibility */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   574
		form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   575
		/* Lock AES */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   576
		wind_update(BEG_UPDATE);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   577
		wind_update(BEG_MCTRL);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   578
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   579
		GEM_locked=SDL_TRUE;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   580
	}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   581
}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   582
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   583
static void GEM_UnlockScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   584
{
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   585
	if (GEM_locked) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   586
		/* Restore screen memory, and send REDRAW to all apps */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   587
		form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   588
		/* Unlock AES */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   589
		wind_update(END_MCTRL);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   590
		wind_update(END_UPDATE);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   591
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   592
		GEM_locked=SDL_FALSE;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   593
	}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   594
}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   595
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   596
SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   597
				int width, int height, int bpp, Uint32 flags)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   598
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   599
	int maxwidth, maxheight;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   600
	Uint32 modeflags, screensize;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   601
	SDL_bool use_shadow1, use_shadow2;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   602
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   603
	GEM_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   604
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   605
	/*--- Verify if asked mode can be used ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   606
	if (flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   607
		maxwidth=VDI_w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   608
		maxheight=VDI_h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   609
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   610
		/* Windowed mode */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   611
		maxwidth=GEM_desk_w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   612
		maxheight=GEM_desk_h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   613
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   614
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   615
	/* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   616
	if ((width & -16) != 0) {
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   617
		width = (width | 15) +1;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   618
	}
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   619
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   620
	if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
		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
   622
		return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
	}
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
	/*--- Allocate the new pixel format for the screen ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
	if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
		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
   628
		return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   631
	screensize = width * height * VDI_pixelsize;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   632
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   633
#ifdef DEBUG_VIDEO_GEM
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   634
	printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   635
#endif
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   636
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   637
	/*--- Allocate shadow buffers if needed, and conversion operations ---*/
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   638
	GEM_bufops=0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   639
	use_shadow1=use_shadow2=SDL_FALSE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   640
	if (VDI_screen && (flags & SDL_FULLSCREEN)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   641
		if (VDI_format==VDI_FORMAT_INTER) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   642
			use_shadow1=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   643
			GEM_bufops = B2S_C2P_1TOS;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   644
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
	} else {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   646
		use_shadow1=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   647
		if (VDI_format==VDI_FORMAT_PACK) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   648
			GEM_bufops = B2S_VROCPYFM_1TOS;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   649
		} else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   650
			use_shadow2=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   651
			GEM_bufops = B2S_C2P_1TO2|B2S_VROCPYFM_2TOS;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   652
		}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   654
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   655
	if (use_shadow1) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   656
		GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   657
		if (GEM_buffer1==NULL) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
			fprintf(stderr,"Unable to allocate shadow buffer\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
			return NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
		}
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   661
		memset(GEM_buffer1, 0, screensize);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   662
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   663
		printf("sdl:video:gem: setvideomode(): allocated buffer 1\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   664
#endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   665
	}
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   666
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   667
	if (use_shadow2) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   668
		GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   669
		if (GEM_buffer2==NULL) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   670
			fprintf(stderr,"Unable to allocate shadow buffer\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   671
			return NULL;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   672
		}
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   673
		memset(GEM_buffer2, 0, screensize);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   674
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   675
		printf("sdl:video:gem: setvideomode(): allocated buffer 2\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   676
#endif
281
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
	/*--- Initialize screen ---*/
508
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   680
	modeflags = 0;
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   681
	if (VDI_bpp == 8) {
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   682
		modeflags |= SDL_HWPALETTE;
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   683
	}
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
   684
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
	if (flags & SDL_FULLSCREEN) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   686
		GEM_LockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   688
		GEM_ClearScreen(this);
281
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
		modeflags |= SDL_FULLSCREEN;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   691
		if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow1) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
			modeflags |= SDL_HWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
		} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
			modeflags |= SDL_SWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   696
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   697
		int posx,posy;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   698
		short x2,y2,w2,h2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   699
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   700
		GEM_UnlockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   701
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   702
		/* Center our window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   703
		posx = GEM_desk_x;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   704
		posy = GEM_desk_y;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   705
		if (width<GEM_desk_w)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   706
			posx += (GEM_desk_w - width) >> 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   707
		if (height<GEM_desk_h)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   708
			posy += (GEM_desk_h - height) >> 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   709
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   710
		/* Calculate our window size and position */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   711
		if (!(flags & SDL_NOFRAME)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   712
			GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   713
			if (flags & SDL_RESIZABLE) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   714
				GEM_win_type |= FULLER|SIZER;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   715
				modeflags |= SDL_RESIZABLE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   716
			}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   717
		} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   718
			GEM_win_type=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   719
			modeflags |= SDL_NOFRAME;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   720
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   721
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   722
		if (!wind_calc(0, GEM_win_type, posx, posy, width, height, &x2, &y2, &w2, &h2)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   723
			GEM_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   724
			fprintf(stderr,"Can not calculate window attributes\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   725
			return NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   726
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   727
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   728
		/* Create window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   729
		GEM_handle=wind_create(GEM_win_type, x2, y2, w2, h2);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   730
		if (GEM_handle<0) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   731
			GEM_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   732
			fprintf(stderr,"Can not create window\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   733
			return NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   734
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   735
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   736
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   737
		printf("sdl:video:gem: handle=%d\n", GEM_handle);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   738
#endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   739
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   740
		/* Setup window name */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   741
		wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   742
		GEM_refresh_name = SDL_FALSE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   743
	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   744
		/* Open the window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   745
		wind_open(GEM_handle,x2,y2,w2,h2);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   746
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   747
		modeflags |= SDL_SWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   748
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   749
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   750
	/* Set up the new mode framebuffer */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   751
	current->flags = modeflags;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   752
	current->w = width;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   753
	current->h = height;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   754
	if (use_shadow1) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   755
		current->pixels = GEM_buffer1;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   756
		current->pitch = width * VDI_pixelsize;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   757
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   758
		current->pixels = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   759
		current->pixels += VDI_pitch * ((VDI_h - height) >> 1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   760
		current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   761
		current->pitch = VDI_pitch;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   762
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   763
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   764
#ifdef DEBUG_VIDEO_GEM
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   765
	printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h);
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   766
#endif
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   767
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   768
	this->UpdateRects = GEM_UpdateRects;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   769
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   770
	/* We're done */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   771
	return(current);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   772
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   773
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   774
static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   775
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   776
	return -1;
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
static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   779
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   780
	return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   781
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   782
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   783
static int GEM_LockHWSurface(_THIS, SDL_Surface *surface)
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
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   786
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   787
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   788
static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   789
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   790
	return;
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   793
static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)
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
	SDL_Surface *surface;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   796
	int i, surf_width;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   797
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   798
	surface = this->screen;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   799
	/* Need to be a multiple of 16 pixels */
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   800
	surf_width=surface->w;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   801
	if ((surf_width & -16) != 0) {
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   802
		surf_width = (surf_width | 15) + 1;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   803
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   804
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   805
	if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   806
		void *destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   807
		int destpitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   808
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   809
		if (GEM_bufops & B2S_C2P_1TOS) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   810
			int destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   811
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   812
			destscr = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   813
			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   814
			destx = (VDI_w - surf_width) >> 1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   815
			destx &= ~15;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   816
			destscr += destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   817
			destpitch = VDI_pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   818
		} else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   819
			destscr = GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   820
			destpitch = surface->pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   821
		}
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   822
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   823
		for (i=0;i<numrects;i++) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   824
			void *source,*destination;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   825
			int x1,x2;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   826
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   827
			x1 = rects[i].x & ~15;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   828
			x2 = rects[i].x+rects[i].w;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   829
			if (x2 & 15) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   830
				x2 = (x2 | 15) +1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   831
			}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   832
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   833
			source = surface->pixels;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   834
			source += surface->pitch * rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   835
			source += x1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   836
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   837
			destination = destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   838
			destination += destpitch * rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   839
			destination += x1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   840
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   841
			SDL_Atari_C2pConvert(
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   842
				source, destination,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   843
				x2-x1, rects[i].h,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   844
				SDL_FALSE,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   845
				surface->pitch, destpitch
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   846
			);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   847
		}
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   848
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   849
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   850
	if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   851
		MFDB mfdb_src;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   852
		short blitcoords[8];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   853
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   854
		mfdb_src.fd_addr=surface->pixels;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   855
		mfdb_src.fd_w=surf_width;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   856
		mfdb_src.fd_h=surface->h;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   857
		mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   858
		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   859
		mfdb_src.fd_stand=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   860
			mfdb_src.fd_r1=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   861
			mfdb_src.fd_r2=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   862
			mfdb_src.fd_r3= 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   863
		if (GEM_bufops & B2S_VROCPYFM_2TOS) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   864
			mfdb_src.fd_addr=GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   865
		}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   866
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   867
		for ( i=0; i<numrects; ++i ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   868
			blitcoords[0] = rects[i].x;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   869
			blitcoords[1] = rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   870
			blitcoords[2] = blitcoords[0] + rects[i].w - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   871
			blitcoords[3] = blitcoords[1] + rects[i].h - 1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   872
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   873
			blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   874
			blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   875
			blitcoords[6] = blitcoords[4] + rects[i].w - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   876
			blitcoords[7] = blitcoords[5] + rects[i].h - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   877
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   878
			vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   879
		}
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
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   882
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   883
static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   884
{
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   885
	short pxy[4], wind_pxy[4];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   886
	int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   887
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   888
	if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   889
		return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   890
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   891
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   892
	for ( i=0; i<numrects; ++i ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   893
		pxy[0] = wind_pxy[0] + rects[i].x;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   894
		pxy[1] = wind_pxy[1] + rects[i].y;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   895
		pxy[2] = rects[i].w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   896
		pxy[3] = rects[i].h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   897
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   898
		GEM_wind_redraw(this, GEM_handle, pxy);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   899
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   900
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   901
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   902
static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   903
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   904
	SDL_Surface *surface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   905
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   906
	surface = this->screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   907
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   908
	if (surface->flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   909
		GEM_UpdateRectsFullscreen(this, numrects, rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   910
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   911
		GEM_UpdateRectsWindowed(this, numrects, rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   912
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   913
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   914
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   915
static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   916
{
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   917
	int surf_width;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   918
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   919
	/* Need to be a multiple of 16 pixels */
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   920
	surf_width=surface->w;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   921
	if ((surf_width & -16) != 0) {
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   922
		surf_width = (surf_width | 15) + 1;
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   923
	}
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   924
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   925
	if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   926
		void *destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   927
		int destpitch;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   928
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   929
		if (GEM_bufops & B2S_C2P_1TOS) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   930
			int destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   931
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   932
			destscr = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   933
			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   934
			destx = (VDI_w - surf_width) >> 1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   935
			destx &= ~15;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   936
			destscr += destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   937
			destpitch = VDI_pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   938
		} else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   939
			destscr = GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   940
			destpitch = surface->pitch;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   941
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   942
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   943
		SDL_Atari_C2pConvert(
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   944
			surface->pixels, destscr,
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   945
			surf_width, surface->h,
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   946
			SDL_FALSE,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   947
			surface->pitch, destpitch
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   948
		);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
   949
	}
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   950
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   951
	if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   952
		MFDB mfdb_src;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   953
		short blitcoords[8];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   954
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   955
		mfdb_src.fd_w=surf_width;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   956
		mfdb_src.fd_h=surface->h;
799
85960507bd2e Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
   957
		mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   958
		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   959
		mfdb_src.fd_stand=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   960
			mfdb_src.fd_r1=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   961
			mfdb_src.fd_r2=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   962
			mfdb_src.fd_r3= 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   963
		if (GEM_bufops & B2S_VROCPYFM_1TOS) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   964
			mfdb_src.fd_addr=surface->pixels;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   965
		} else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   966
			mfdb_src.fd_addr=GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   967
		}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   968
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   969
		blitcoords[0] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   970
		blitcoords[1] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   971
		blitcoords[2] = surface->w - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   972
		blitcoords[3] = surface->h - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   973
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   974
		blitcoords[4] = (VDI_w - surface->w) >> 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   975
		blitcoords[5] = (VDI_h - surface->h) >> 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   976
		blitcoords[6] = blitcoords[4] + surface->w - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   977
		blitcoords[7] = blitcoords[5] + surface->h - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   978
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   979
		vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
   980
	}
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   981
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   982
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   983
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   984
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   985
static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   986
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   987
	short	pxy[8];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   988
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   989
	/* Update the whole window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   990
	wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   991
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   992
	GEM_wind_redraw(this, GEM_handle, pxy);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   993
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   994
	return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   995
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   996
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   997
static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   998
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   999
	if (surface->flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1000
		return GEM_FlipHWSurfaceFullscreen(this, surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1001
	} else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1002
		return GEM_FlipHWSurfaceWindowed(this, surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1003
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1004
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1005
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1006
static int GEM_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
  1007
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1008
	int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1009
	SDL_Surface *surface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1010
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1011
#ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1012
	printf("sdl:video:gem: setcolors()\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1013
#endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1014
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1015
	/* Do not change palette in True Colour */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1016
	surface = this->screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1017
	if (surface->format->BitsPerPixel > 8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1018
		return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1019
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1020
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1021
	for(i = 0; i < ncolors; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1022
	{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1023
		int		r, g, b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1024
		short	rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1025
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1026
		r = colors[i].r;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1027
		g = colors[i].g;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1028
		b = colors[i].b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1029
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1030
		rgb[0] = (1000 * r) / 255;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1031
		rgb[1] = (1000 * g) / 255;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1032
		rgb[2] = (1000 * b) / 255;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1033
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1034
		vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1035
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1036
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1037
	return(1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1038
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1039
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1040
#if 0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1041
static int GEM_ToggleFullScreen(_THIS, int on)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1042
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1043
	if (on) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
  1044
		GEM_LockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1045
	} else {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
  1046
		GEM_UnlockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1047
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1048
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1049
	return(1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1050
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1051
#endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1052
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1053
/* 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
  1054
   another SDL video routine -- notably UpdateRects.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1055
*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1056
void GEM_VideoQuit(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1057
{
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
  1058
	SDL_AtariXbios_RestoreVectors();
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
  1059
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1060
	GEM_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1061
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
  1062
	GEM_UnlockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1063
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1064
	appl_exit();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1065
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1066
	/* Restore palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1067
	if (VDI_oldnumcolors) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1068
		int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1069
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1070
		for(i = 0; i < VDI_oldnumcolors; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1071
			short	rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1072
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1073
			rgb[0] = VDI_oldpalette[i][0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1074
			rgb[1] = VDI_oldpalette[i][1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1075
			rgb[2] = VDI_oldpalette[i][2];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1076
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1077
			vs_color(VDI_handle, i, rgb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1078
		}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1079
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1080
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1081
	/* Close VDI workstation */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1082
	if (VDI_handle) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1083
		v_clsvwk(VDI_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1084
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1085
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1086
	/* Free mode list */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1087
	if (SDL_modelist[0]) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1088
		free(SDL_modelist[0]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1089
		SDL_modelist[0]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1090
	}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1091
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1092
	this->screen->pixels = NULL;	
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1093
}
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1094
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1095
void GEM_wind_redraw(_THIS, int winhandle, short *inside)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1096
{
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1097
	short todo[4];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1098
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1099
	/* Tell AES we are going to update */
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
  1100
	wind_update(BEG_UPDATE);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1101
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1102
	v_hide_c(VDI_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1103
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1104
	/* Browse the rectangle list to redraw */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1105
	if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1106
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1107
		while (todo[2] && todo[3]) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1108
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1109
			if (rc_intersect((GRECT *)inside,(GRECT *)todo)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1110
				todo[2] += todo[0]-1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1111
				todo[3] += todo[1]-1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1112
				refresh_window(this, winhandle, todo);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1113
			}
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1114
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1115
			if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
  1116
				break;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: