annotate src/video/gem/SDL_gemvideo.c @ 989:475166d13b44

Factorize OSMesa OpenGL code for Atari drivers
author Patrice Mandin <patmandin@gmail.com>
date Thu, 25 Nov 2004 15:47:49 +0000
parents 24b5c3ad4852
children 12b13601a544
rev   line source
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"
986
952ec1ddcb58 Add conversion routines for unsupported screen formats
Patrice Mandin <patmandin@gmail.com>
parents: 984
diff changeset
50 #include "SDL_endian.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #include "SDL_sysvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 #include "SDL_pixels_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 #include "SDL_events_c.h"
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
54 #include "SDL_cursor_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 #include "SDL_ataric2p_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 #include "SDL_atarieddi_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 #include "SDL_atarimxalloc_c.h"
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
59 #include "SDL_atarigl_c.h"
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
60
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 #include "SDL_gemvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 #include "SDL_gemevents_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 #include "SDL_gemmouse_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 #include "SDL_gemwm_c.h"
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
65 #include "SDL_xbiosevents_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 /* Defines */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
69 /*#define DEBUG_VIDEO_GEM 1*/
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
70
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 #define GEM_VID_DRIVER_NAME "gem"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
73 #undef MIN
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
74 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
75 #undef MAX
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
76 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
77
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 /* Variables */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 static unsigned char vdi_index[256] = {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 0, 2, 3, 6, 4, 7, 5, 8,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 9, 10, 11, 14, 12, 15, 13, 255
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 static const unsigned char empty_name[]="";
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 /* Initialization/Query functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 static int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 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
90 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
91 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
92 static void GEM_VideoQuit(_THIS);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 /* Hardware surface functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 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
101 #if 0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 static int GEM_ToggleFullScreen(_THIS, int on);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 #endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 /* Internal functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 static void GEM_FreeBuffers(_THIS);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
107 static void GEM_ClearScreen(_THIS);
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
108 static void GEM_ClearRect(_THIS, short *rect);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
109 static void GEM_LockScreen(_THIS);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
110 static void GEM_UnlockScreen(_THIS);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 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
112
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
113 #ifdef HAVE_OPENGL
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
114 /* OpenGL functions */
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
115 static void GEM_GL_SwapBuffers(_THIS);
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
116 #endif
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
117
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 /* GEM driver bootstrap functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 static int GEM_Available(void)
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 /* Test if AES available */
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 508
diff changeset
123 if (appl_init() == -1)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 appl_exit();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 }
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 static void GEM_DeleteDevice(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 free(device->hidden);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 free(device);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 static SDL_VideoDevice *GEM_CreateDevice(int devindex)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 SDL_VideoDevice *device;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 /* Initialize all variables that we clean on shutdown */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 memset(device, 0, (sizeof *device));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 device->hidden = (struct SDL_PrivateVideoData *)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 malloc((sizeof *device->hidden));
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
146 device->gl_data = (struct SDL_PrivateGLData *)
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
147 malloc((sizeof *device->gl_data));
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 if ( (device == NULL) || (device->hidden == NULL) ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 SDL_OutOfMemory();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 if ( device ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 free(device);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 memset(device->hidden, 0, (sizeof *device->hidden));
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
157 memset(device->gl_data, 0, sizeof(*device->gl_data));
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 /* Set the function pointers */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 device->VideoInit = GEM_VideoInit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 device->ListModes = GEM_ListModes;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 device->SetVideoMode = GEM_SetVideoMode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 device->SetColors = GEM_SetColors;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 device->UpdateRects = NULL /*GEM_UpdateRects*/;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 device->VideoQuit = GEM_VideoQuit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 device->AllocHWSurface = GEM_AllocHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 device->LockHWSurface = GEM_LockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 device->UnlockHWSurface = GEM_UnlockHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 device->FlipHWSurface = GEM_FlipHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 device->FreeHWSurface = GEM_FreeHWSurface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 /* Window manager */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 device->SetCaption = GEM_SetCaption;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
175 device->SetIcon = GEM_SetIcon;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 device->IconifyWindow = GEM_IconifyWindow;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 device->GrabInput = GEM_GrabInput;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 /* Events */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 device->InitOSKeymap = GEM_InitOSKeymap;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 device->PumpEvents = GEM_PumpEvents;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 /* Mouse */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 device->FreeWMCursor = GEM_FreeWMCursor;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 device->CreateWMCursor = GEM_CreateWMCursor;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 device->ShowWMCursor = GEM_ShowWMCursor;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
187 device->WarpWMCursor = NULL /*GEM_WarpWMCursor*/;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 device->CheckMouseMode = GEM_CheckMouseMode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
190 #ifdef HAVE_OPENGL
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
191 /* OpenGL functions */
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
192 device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
193 device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
194 device->GL_GetAttribute = SDL_AtariGL_GetAttribute;
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
195 device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
196 device->GL_SwapBuffers = GEM_GL_SwapBuffers;
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
197 #endif
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
198
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
199 /* Joystick + Mouse relative motion */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
200 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
201
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 device->free = GEM_DeleteDevice;
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 return device;
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 VideoBootStrap GEM_bootstrap = {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 GEM_VID_DRIVER_NAME, "Atari GEM video driver",
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 GEM_Available, GEM_CreateDevice
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 };
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 static void VDI_ReadExtInfo(_THIS, short *work_out)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 unsigned long EdDI_version;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 unsigned long cookie_EdDI;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 Uint32 num_colours;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 Uint16 clut_type, num_bits;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 /* Read EdDI informations */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 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
225
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 vq_scrninfo(VDI_handle, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 VDI_format = work_out[0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 clut_type = work_out[1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 num_bits = work_out[2];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 num_colours = *((Uint32 *) &work_out[3]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 /* 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
234 * 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
235 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 if (EdDI_version >= EDDI_11) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 VDI_pitch = work_out[5];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 VDI_screen = (void *) *((unsigned long *) &work_out[6]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 switch(clut_type) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 case VDI_CLUT_HARDWARE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 Uint16 *tmp_p;
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 tmp_p = (Uint16 *)&work_out[16];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 for (i=0;i<256;i++) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
250 vdi_index[*tmp_p++] = i;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 case VDI_CLUT_SOFTWARE:
800
60a4293ffea9 When commiting code, cleanup before doing it
Patrice Mandin <patmandin@gmail.com>
parents: 799
diff changeset
255 {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 int component; /* red, green, blue, alpha, overlay */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 int num_bit;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 unsigned short *tmp_p;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 /* We can build masks with info here */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 tmp_p = (unsigned short *) &work_out[16];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 for (component=0;component<5;component++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 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
264 unsigned short valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 valeur = *tmp_p++;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 if (valeur == 0xffff) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 continue;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 switch(component) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 case 0:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 VDI_redmask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 case 1:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 VDI_greenmask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 case 2:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 VDI_bluemask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 case 3:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 VDI_alphamask |= 1<< valeur;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 break;
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 }
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
288 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
290 /* Remove lower green bits for Intel endian screen */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
291 if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
292 VDI_greenmask &= ~(7<<13);
281
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 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 case VDI_CLUT_NONE:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
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 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 short work_in[12], work_out[272], dummy;
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 /* 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
306 if (appl_init() == -1) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 fprintf(stderr,"Can not open AES\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 /* Read version and features */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
312 GEM_version = aes_global[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
313 if (GEM_version >= 0x0410) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
314 short ap_gout[4], errorcode;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
316 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
317 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
318 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
319
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 GEM_wfeatures=0;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
321 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
322 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
323 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
324 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
325
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
326 if (errorcode==0) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 GEM_wfeatures=ap_gout[0];
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
328
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
329 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
330 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
331 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
332 } else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
333 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
334 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
335 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
336 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 }
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 /* Ask VDI physical workstation handle opened by AES */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 if (VDI_handle<1) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 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
344 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 /* Open virtual VDI workstation */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 work_in[0]=Getrez()+2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 for(i = 1; i < 10; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 work_in[i] = 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 work_in[10] = 2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 v_opnvwk(work_in, &VDI_handle, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 if (VDI_handle == 0) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 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
356 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 /* Read fullscreen size */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 VDI_w = work_out[0] + 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 VDI_h = work_out[1] + 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 /* Read desktop size and position */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 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
365 fprintf(stderr,"Can not read desktop properties\n");
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 /* Read bit depth */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 vq_extnd(VDI_handle, 1, work_out);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 VDI_bpp = work_out[4];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 VDI_oldnumcolors=0;
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 switch(VDI_bpp) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 case 8:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 VDI_pixelsize=1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 case 15:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 case 16:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 VDI_pixelsize=2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 case 24:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 VDI_pixelsize=3;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 case 32:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 VDI_pixelsize=4;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 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
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 /* Setup hardware -> VDI palette mapping */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 for(i = 16; i < 255; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 vdi_index[i] = i;
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 vdi_index[255] = 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 /* Save current palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 if (VDI_bpp>8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 VDI_oldnumcolors=1<<8;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 VDI_oldnumcolors=1<<VDI_bpp;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 for(i = 0; i < VDI_oldnumcolors; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 short rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 vq_color(VDI_handle, i, 0, rgb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 VDI_oldpalette[i][0] = rgb[0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 VDI_oldpalette[i][1] = rgb[1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 VDI_oldpalette[i][2] = rgb[2];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 /* Setup screen info */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 GEM_title_name = empty_name;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 GEM_icon_name = empty_name;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 GEM_handle = -1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 GEM_locked = SDL_FALSE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 GEM_win_fulled = SDL_FALSE;
926
83db694556eb Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents: 925
diff changeset
423 GEM_fullscreen = SDL_FALSE;
964
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
424 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers are setup */
281
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 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
427 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
428 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
429 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
430 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
431
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
432 #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
433 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
434 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
435 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
436 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
437 );
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
438 #endif
281
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 /* Setup destination mfdb */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 VDI_dst_mfdb.fd_addr = NULL;
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 /* Update hardware info */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 this->info.hw_available = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 this->info.video_mem = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 /* Determine the screen depth */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 /* we change this during the SDL_SetVideoMode implementation... */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 vformat->BitsPerPixel = VDI_bpp;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 /* Set mouse cursor to arrow */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 graf_mouse(ARROW, NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 /* Init chunky to planar routine */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
455 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
456
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
457 /* Setup VDI fill functions */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
458 vsf_color(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
459 vsf_interior(VDI_handle,1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
460 vsf_perimeter(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
461
902
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
462 /* Fill video modes list */
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
463 SDL_modelist[0] = malloc(sizeof(SDL_Rect));
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
464 SDL_modelist[0]->x = 0;
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
465 SDL_modelist[0]->y = 0;
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
466 SDL_modelist[0]->w = VDI_w;
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
467 SDL_modelist[0]->h = VDI_h;
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
468
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
469 SDL_modelist[1] = NULL;
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
470
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
471 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
472 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
473 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 /* We're done! */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 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
480 {
902
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
481 if (format->BitsPerPixel != VDI_bpp) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 return ((SDL_Rect **)NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 }
902
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
484
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
485 if (flags & SDL_FULLSCREEN) {
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
486 return (SDL_modelist);
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
487 }
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
488
99f439d6ee4a Forgot to initialize video mode list
Patrice Mandin <patmandin@gmail.com>
parents: 800
diff changeset
489 return((SDL_Rect **)-1);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 }
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 static void GEM_FreeBuffers(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 {
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
494 #ifdef HAVE_OPENGL
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
495 SDL_AtariGL_Quit(this);
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
496 #endif
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
497
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 /* Release buffer */
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
499 if ( GEM_buffer2 ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
500 free( GEM_buffer2 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
501 GEM_buffer2=NULL;
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
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
504 if ( GEM_buffer1 ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
505 free( GEM_buffer1 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
506 GEM_buffer1=NULL;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
510 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
511 {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
512 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
513
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
514 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
515 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
516
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
517 vsf_color(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
518 vsf_interior(VDI_handle,1);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
519 vsf_perimeter(VDI_handle,0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
520 v_bar(VDI_handle, rect);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
521
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
522 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
523 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
524
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
525 static void GEM_ClearScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
526 {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
527 short pxy[4];
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
528
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
529 v_hide_c(VDI_handle);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
530
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
531 pxy[0] = pxy[1] = 0;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
532 pxy[2] = VDI_w - 1;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
533 pxy[3] = VDI_h - 1;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
534 GEM_ClearRect(this, pxy);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
535
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
536 v_show_c(VDI_handle, 1);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
537 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
538
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
539 static void GEM_LockScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
540 {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
541 if (!GEM_locked) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
542 /* Lock AES */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
543 wind_update(BEG_UPDATE);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
544 wind_update(BEG_MCTRL);
917
24852aeb0657 Lock the screen before doing its backup
Patrice Mandin <patmandin@gmail.com>
parents: 902
diff changeset
545 /* Reserve memory space, used to be sure of compatibility */
24852aeb0657 Lock the screen before doing its backup
Patrice Mandin <patmandin@gmail.com>
parents: 902
diff changeset
546 form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h);
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
547
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
548 GEM_locked=SDL_TRUE;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
549 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
550 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
551
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
552 static void GEM_UnlockScreen(_THIS)
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
553 {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
554 if (GEM_locked) {
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
555 /* Restore screen memory, and send REDRAW to all apps */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
556 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
557 /* Unlock AES */
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
558 wind_update(END_MCTRL);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
559 wind_update(END_UPDATE);
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
560
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
561 GEM_locked=SDL_FALSE;
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
562 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
563 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
564
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 int width, int height, int bpp, Uint32 flags)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 int maxwidth, maxheight;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 Uint32 modeflags, screensize;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
570 SDL_bool use_shadow1, use_shadow2;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 /*--- Verify if asked mode can be used ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 if (flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 maxwidth=VDI_w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 maxheight=VDI_h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 /* Windowed mode */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 maxwidth=GEM_desk_w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 maxheight=GEM_desk_h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581
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
582 /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
918
17822f1f9674 Wrongly test if width multiple of 16
Patrice Mandin <patmandin@gmail.com>
parents: 917
diff changeset
583 if ((width & 15) != 0) {
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
584 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
585 }
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
586
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 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
589 return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 /*--- Allocate the new pixel format for the screen ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 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
594 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
595 return(NULL);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
598 screensize = width * height * VDI_pixelsize;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
599
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
600 #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
601 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
602 #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
603
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
604 /*--- Allocate shadow buffers if needed, and conversion operations ---*/
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
605 GEM_FreeBuffers(this);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
606
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
607 GEM_bufops=0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
608 use_shadow1=use_shadow2=SDL_FALSE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
609 if (VDI_screen && (flags & SDL_FULLSCREEN)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
610 if (VDI_format==VDI_FORMAT_INTER) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
611 use_shadow1=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
612 GEM_bufops = B2S_C2P_1TOS;
281
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 } else {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
615 use_shadow1=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
616 if (VDI_format==VDI_FORMAT_PACK) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
617 GEM_bufops = B2S_VROCPYFM_1TOS;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
618 } else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
619 use_shadow2=SDL_TRUE;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
620 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
621 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
624 if (use_shadow1) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
625 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
626 if (GEM_buffer1==NULL) {
920
bbefeed8134d Use SDL_SetError instead of fprintf
Patrice Mandin <patmandin@gmail.com>
parents: 918
diff changeset
627 SDL_SetError("Unable to allocate shadow buffer");
281
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 }
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
630 memset(GEM_buffer1, 0, screensize);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
631 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
632 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
633 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
634 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
635
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
636 if (use_shadow2) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
637 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
638 if (GEM_buffer2==NULL) {
920
bbefeed8134d Use SDL_SetError instead of fprintf
Patrice Mandin <patmandin@gmail.com>
parents: 918
diff changeset
639 SDL_SetError("Unable to allocate shadow buffer");
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
640 return NULL;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
641 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
642 memset(GEM_buffer2, 0, screensize);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
643 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
644 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
645 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 /*--- Initialize screen ---*/
508
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
649 modeflags = 0;
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
650 if (VDI_bpp == 8) {
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
651 modeflags |= SDL_HWPALETTE;
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
652 }
9ff7e90aaa94 Fixed gamma correction in Atari video drivers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 319
diff changeset
653
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 if (flags & SDL_FULLSCREEN) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
655 GEM_LockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
657 GEM_ClearScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 modeflags |= SDL_FULLSCREEN;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
660 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
661 modeflags |= SDL_HWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 modeflags |= SDL_SWSURFACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 }
926
83db694556eb Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents: 925
diff changeset
665
83db694556eb Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents: 925
diff changeset
666 GEM_fullscreen = SDL_TRUE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 } else {
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
668 int old_win_type;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 short x2,y2,w2,h2;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
671 GEM_UnlockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672
923
2748679027ff Correctly center window on creation
Patrice Mandin <patmandin@gmail.com>
parents: 921
diff changeset
673 /* Set window gadgets */
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
674 old_win_type = GEM_win_type;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 if (!(flags & SDL_NOFRAME)) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 if (flags & SDL_RESIZABLE) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 GEM_win_type |= FULLER|SIZER;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 modeflags |= SDL_RESIZABLE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 GEM_win_type=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 modeflags |= SDL_NOFRAME;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 }
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
685 modeflags |= SDL_SWSURFACE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
687 /* Recreate window ? only for different widget or non-created window */
959
51ec8fc8bedb No need to close the window when going to fullscreen mode
Patrice Mandin <patmandin@gmail.com>
parents: 926
diff changeset
688 if ((old_win_type != GEM_win_type) || (GEM_handle < 0)) {
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
689 /* Calculate window size */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
690 if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
691 GEM_FreeBuffers(this);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
692 SDL_SetError("Can not calculate window attributes");
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
693 return NULL;
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
694 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
696 /* Center window */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
697 x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
698 y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
923
2748679027ff Correctly center window on creation
Patrice Mandin <patmandin@gmail.com>
parents: 921
diff changeset
699
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
700 /* Destroy existing window */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
701 if (GEM_handle >= 0) {
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
702 wind_close(GEM_handle);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
703 wind_delete(GEM_handle);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
704 }
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
705
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
706 /* Create window */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
707 GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
708 if (GEM_handle<0) {
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
709 GEM_FreeBuffers(this);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
710 SDL_SetError("Can not create window");
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
711 return NULL;
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
712 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
713
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
714 #ifdef DEBUG_VIDEO_GEM
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
715 printf("sdl:video:gem: handle=%d\n", GEM_handle);
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
716 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
717
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
718 /* Setup window name */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
719 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
720 GEM_refresh_name = SDL_FALSE;
959
51ec8fc8bedb No need to close the window when going to fullscreen mode
Patrice Mandin <patmandin@gmail.com>
parents: 926
diff changeset
721
51ec8fc8bedb No need to close the window when going to fullscreen mode
Patrice Mandin <patmandin@gmail.com>
parents: 926
diff changeset
722 /* Open the window */
51ec8fc8bedb No need to close the window when going to fullscreen mode
Patrice Mandin <patmandin@gmail.com>
parents: 926
diff changeset
723 wind_open(GEM_handle,x2,y2,w2,h2);
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
724 }
926
83db694556eb Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents: 925
diff changeset
725
83db694556eb Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents: 925
diff changeset
726 GEM_fullscreen = SDL_FALSE;
281
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 /* Set up the new mode framebuffer */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 current->w = width;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 current->h = height;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
732 if (use_shadow1) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
733 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
734 current->pitch = width * VDI_pixelsize;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 current->pixels = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 current->pixels += VDI_pitch * ((VDI_h - height) >> 1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 current->pitch = VDI_pitch;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
742 #ifdef HAVE_OPENGL
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
743 if (flags & SDL_OPENGL) {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
744 if (!SDL_AtariGL_Init(this, current)) {
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
745 GEM_FreeBuffers(this);
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
746 SDL_SetError("Can not create OpenGL context");
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
747 return NULL;
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
748 }
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
749
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
750 modeflags |= SDL_OPENGL;
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
751 }
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
752 #endif
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
753
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
754 current->flags = modeflags;
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
755
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 #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
757 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
758 #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
759
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 this->UpdateRects = GEM_UpdateRects;
964
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
761 GEM_lock_redraw = SDL_FALSE; /* Enable redraw */
281
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 /* We're done */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 return(current);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
769 return -1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770 }
800
60a4293ffea9 When commiting code, cleanup before doing it
Patrice Mandin <patmandin@gmail.com>
parents: 799
diff changeset
771
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface)
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 return;
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779 return(0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780 }
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 static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 return;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
785 }
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 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
788 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 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
790 int i, surf_width;
281
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 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
793 /* 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
794 surf_width=surface->w;
918
17822f1f9674 Wrongly test if width multiple of 16
Patrice Mandin <patmandin@gmail.com>
parents: 917
diff changeset
795 if ((surf_width & 15) != 0) {
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 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
797 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
799 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
800 void *destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
801 int destpitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
802
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
803 if (GEM_bufops & B2S_C2P_1TOS) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
804 int destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
805
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 destscr = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 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
808 destx = (VDI_w - surf_width) >> 1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 destx &= ~15;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
810 destscr += destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
811 destpitch = VDI_pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
812 } else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
813 destscr = GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
814 destpitch = surface->pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
815 }
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
816
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
817 for (i=0;i<numrects;i++) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
818 void *source,*destination;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
819 int x1,x2;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
820
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
821 x1 = rects[i].x & ~15;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
822 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
823 if (x2 & 15) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
824 x2 = (x2 | 15) +1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
825 }
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 source = surface->pixels;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
828 source += surface->pitch * rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
829 source += x1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
830
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
831 destination = destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
832 destination += destpitch * rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
833 destination += x1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
834
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
835 SDL_Atari_C2pConvert(
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
836 source, destination,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
837 x2-x1, rects[i].h,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
838 SDL_FALSE,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
839 surface->pitch, destpitch
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
840 );
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
841 }
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
842 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
844 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
845 MFDB mfdb_src;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
846 short blitcoords[8];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
847
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
848 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
849 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
850 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
851 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
852 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
853 mfdb_src.fd_stand=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
854 mfdb_src.fd_r1=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
855 mfdb_src.fd_r2=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
856 mfdb_src.fd_r3= 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
857 if (GEM_bufops & B2S_VROCPYFM_2TOS) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
858 mfdb_src.fd_addr=GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
859 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
860
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
861 for ( i=0; i<numrects; ++i ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
862 blitcoords[0] = rects[i].x;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
863 blitcoords[1] = rects[i].y;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
864 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
865 blitcoords[3] = blitcoords[1] + rects[i].h - 1;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
866
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
867 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
868 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
869 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
870 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
871
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
872 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
873 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
876
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
877 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
878 {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
879 short pxy[4], wind_pxy[4];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
880 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
881
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
882 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
883 return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
884 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
885
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
886 for ( i=0; i<numrects; ++i ) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 pxy[0] = wind_pxy[0] + rects[i].x;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
888 pxy[1] = wind_pxy[1] + rects[i].y;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
889 pxy[2] = rects[i].w;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
890 pxy[3] = rects[i].h;
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 GEM_wind_redraw(this, GEM_handle, pxy);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 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
897 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 SDL_Surface *surface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899
964
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
900 if (GEM_lock_redraw) {
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
901 return;
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
902 }
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
903
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
904 surface = this->screen;
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 if (surface->flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 GEM_UpdateRectsFullscreen(this, numrects, rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 GEM_UpdateRectsWindowed(this, numrects, rects);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 }
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 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
914 {
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
915 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
916
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 /* 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
918 surf_width=surface->w;
918
17822f1f9674 Wrongly test if width multiple of 16
Patrice Mandin <patmandin@gmail.com>
parents: 917
diff changeset
919 if ((surf_width & 15) != 0) {
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
920 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
921 }
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
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
923 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
924 void *destscr;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
925 int destpitch;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
926
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
927 if (GEM_bufops & B2S_C2P_1TOS) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 int destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
929
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 destscr = VDI_screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 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
932 destx = (VDI_w - surf_width) >> 1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 destx &= ~15;
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
934 destscr += destx;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
935 destpitch = VDI_pitch;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
936 } else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
937 destscr = GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
938 destpitch = surface->pitch;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
941 SDL_Atari_C2pConvert(
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
942 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
943 surf_width, surface->h,
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
944 SDL_FALSE,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
945 surface->pitch, destpitch
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
946 );
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
947 }
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
948
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
949 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
950 MFDB mfdb_src;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
951 short blitcoords[8];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952
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
953 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
954 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
955 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
956 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
957 mfdb_src.fd_stand=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
958 mfdb_src.fd_r1=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
959 mfdb_src.fd_r2=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
960 mfdb_src.fd_r3= 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
961 if (GEM_bufops & B2S_VROCPYFM_1TOS) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
962 mfdb_src.fd_addr=surface->pixels;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
963 } else {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
964 mfdb_src.fd_addr=GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
965 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
967 blitcoords[0] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
968 blitcoords[1] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
969 blitcoords[2] = surface->w - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
970 blitcoords[3] = surface->h - 1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
971
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
972 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
973 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
974 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
975 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
976
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
977 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
978 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
979
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
980 return(0);
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
983 static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface)
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 short pxy[8];
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 /* Update the whole window */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
988 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
989
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
990 GEM_wind_redraw(this, GEM_handle, pxy);
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 return(0);
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
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
995 static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996 {
964
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
997 if (GEM_lock_redraw) {
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
998 return(0);
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
999 }
d9209754ebee Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents: 959
diff changeset
1000
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1001 if (surface->flags & SDL_FULLSCREEN) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1002 return GEM_FlipHWSurfaceFullscreen(this, surface);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003 } else {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004 return GEM_FlipHWSurfaceWindowed(this, surface);
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 }
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 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
1009 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1010 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1011 SDL_Surface *surface;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1012
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1013 #ifdef DEBUG_VIDEO_GEM
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1014 printf("sdl:video:gem: setcolors()\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1015 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1016
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1017 /* Do not change palette in True Colour */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 surface = this->screen;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1019 if (surface->format->BitsPerPixel > 8) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1021 }
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 for(i = 0; i < ncolors; i++)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1025 int r, g, b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1026 short rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1027
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1028 r = colors[i].r;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1029 g = colors[i].g;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1030 b = colors[i].b;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032 rgb[0] = (1000 * r) / 255;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1033 rgb[1] = (1000 * g) / 255;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1034 rgb[2] = (1000 * b) / 255;
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 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
1037 }
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 return(1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1041
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042 #if 0
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1043 static int GEM_ToggleFullScreen(_THIS, int on)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1044 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1045 if (on) {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
1046 GEM_LockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1047 } else {
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
1048 GEM_UnlockScreen(this);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1049 }
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 return(1);
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 #endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1054
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1055 /* 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
1056 another SDL video routine -- notably UpdateRects.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1057 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1058 void GEM_VideoQuit(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1059 {
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1060 SDL_AtariXbios_RestoreVectors();
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1061
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1062 GEM_FreeBuffers(this);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1063
925
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1064 /* Destroy window */
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1065 if (GEM_handle>=0) {
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1066 wind_close(GEM_handle);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1067 wind_delete(GEM_handle);
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1068 GEM_handle=-1;
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1069 }
15ff92ae7e1b Do not destroy window on resize, so we can go back to original size from maximized size
Patrice Mandin <patmandin@gmail.com>
parents: 924
diff changeset
1070
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
1071 GEM_UnlockScreen(this);
281
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 appl_exit();
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1074
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1075 /* Restore palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1076 if (VDI_oldnumcolors) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1077 int i;
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 for(i = 0; i < VDI_oldnumcolors; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1080 short rgb[3];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1081
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1082 rgb[0] = VDI_oldpalette[i][0];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1083 rgb[1] = VDI_oldpalette[i][1];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1084 rgb[2] = VDI_oldpalette[i][2];
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 vs_color(VDI_handle, i, rgb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1087 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1088 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1089
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1090 /* Close VDI workstation */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1091 if (VDI_handle) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1092 v_clsvwk(VDI_handle);
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 /* Free mode list */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1096 if (SDL_modelist[0]) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1097 free(SDL_modelist[0]);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1098 SDL_modelist[0]=NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1099 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1100
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1101 this->screen->pixels = NULL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1102 }
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 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
1105 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1106 short todo[4];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1107
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1108 /* Tell AES we are going to update */
319
189a6a3416c7 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
1109 wind_update(BEG_UPDATE);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1110
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1111 v_hide_c(VDI_handle);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1112
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1113 /* 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
1114 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
1115
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1116 while (todo[2] && todo[3]) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1117
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1118 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
1119 todo[2] += todo[0]-1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1120 todo[3] += todo[1]-1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1121 refresh_window(this, winhandle, todo);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1122 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1123
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1124 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
1125 break;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1126 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1127 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1128
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1129 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1130
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1131 /* Update finished */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1132 wind_update(END_UPDATE);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1133
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1134 v_show_c(VDI_handle,1);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1135 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1136
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1137 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
1138 {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1139 MFDB mfdb_src;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1140 short pxy[8],wind_pxy[8];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1141 SDL_Surface *surface;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1142 int iconified;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1143
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1144 /* Is window iconified ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1145 iconified = 0;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1146 /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1147 if (wind_get(winhandle, WF_ICONIFY, &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
1148 iconified = wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1149 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1150 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1151
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1152 if (wind_get(winhandle, 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
1153 return;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1154 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1155
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1156 if (iconified && GEM_icon) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1157 short icon_rect[4], dst_rect[4];
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1158 short iconx,icony;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1159
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1160 surface = GEM_icon;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1161
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1162 GEM_ClearRect(this, rect);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1163
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1164 /* Calculate centered icon(x,y,w,h) relative to window */
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1165 iconx = (wind_pxy[2]-surface->w)>>1;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1166 icony = (wind_pxy[3]-surface->h)>>1;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1167
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1168 icon_rect[0] = iconx;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1169 icon_rect[1] = icony;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1170 icon_rect[2] = surface->w;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1171 icon_rect[3] = surface->h;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1172
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1173 /* Calculate redraw rectangle(x,y,w,h) relative to window */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1174 dst_rect[0] = rect[0]-wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1175 dst_rect[1] = rect[1]-wind_pxy[1];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1176 dst_rect[2] = rect[2]-rect[0]+1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1177 dst_rect[3] = rect[3]-rect[1]+1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1178
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1179 /* Does the icon rectangle must be redrawn ? */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1180 if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1181 return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1182 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1183
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
1184 #if DEBUG_VIDEO_GEM
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1185 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n",
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1186 surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1187 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n",
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1188 icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1189 printf("sdl:video:gem: refresh_window(): draw icon\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1190 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1191
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1192 /* Calculate icon(x1,y1,x2,y2) relative to screen */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1193 icon_rect[0] += wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1194 icon_rect[1] += wind_pxy[1];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1195 icon_rect[2] += icon_rect[0]-1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1196 icon_rect[3] += icon_rect[1]-1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1197
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1198 /* Calculate intersection rectangle to redraw */
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1199 pxy[4]=pxy[0]=MAX(icon_rect[0],rect[0]);
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1200 pxy[5]=pxy[1]=MAX(icon_rect[1],rect[1]);
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1201 pxy[6]=pxy[2]=MIN(icon_rect[2],rect[2]);
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1202 pxy[7]=pxy[3]=MIN(icon_rect[3],rect[3]);
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1203
737
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1204 /* Calculate icon source image pos relative to window */
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1205 pxy[0] -= wind_pxy[0]+iconx;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1206 pxy[1] -= wind_pxy[1]+icony;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1207 pxy[2] -= wind_pxy[0]+iconx;
7e4347dd2f9c Small fix for iconification
Patrice Mandin <patmandin@gmail.com>
parents: 736
diff changeset
1208 pxy[3] -= wind_pxy[1]+icony;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1209
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1210 } else {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1211 surface = this->screen;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1212
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
1213 #if DEBUG_VIDEO_GEM
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1214 printf("sdl:video:gem: refresh_window(): draw frame buffer\n");
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1215 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1216
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1217 /* Redraw all window content */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1218 pxy[0] = rect[0]-wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1219 pxy[1] = rect[1]-wind_pxy[1];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1220 pxy[2] = rect[2]-wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1221 pxy[3] = rect[3]-wind_pxy[1];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1222
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1223 pxy[4] = rect[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1224 pxy[5] = rect[1];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1225 pxy[6] = rect[2];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1226 pxy[7] = rect[3];
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1227 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1228
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1229 if (GEM_bufops & B2S_C2P_1TO2) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1230 void *src, *dest;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1231 int x1,x2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1232
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1233 x1 = (rect[0]-wind_pxy[0]) & ~15;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1234 x2 = rect[2]-wind_pxy[0];
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1235 if (x2 & 15) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1236 x2 = (x2 | 15) +1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1237 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1238
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1239 src = surface->pixels;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1240 src += surface->pitch * (rect[1]-wind_pxy[1]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1241 src += x1;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1242
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1243 dest = GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1244 dest += surface->pitch * (rect[1]-wind_pxy[1]);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1245 dest += x1;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1246
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1247 SDL_Atari_C2pConvert(
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1248 src, dest,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1249 x2-x1, rect[3]-rect[1]+1,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1250 SDL_FALSE,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1251 surface->pitch, surface->pitch
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1252 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1253 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1254
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1255 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
1256 {
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
1257 int 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
1258
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
1259 /* 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
1260 width=surface->w;
918
17822f1f9674 Wrongly test if width multiple of 16
Patrice Mandin <patmandin@gmail.com>
parents: 917
diff changeset
1261 if ((width & 15) != 0) {
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
1262 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
1263 }
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
1264 mfdb_src.fd_w=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
1265 }
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1266 mfdb_src.fd_h=surface->h;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1267 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
1268 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1269 mfdb_src.fd_stand=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1270 mfdb_src.fd_r1=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1271 mfdb_src.fd_r2=
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1272 mfdb_src.fd_r3= 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1273
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1274 if (GEM_bufops & B2S_VROCPYFM_2TOS) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1275 mfdb_src.fd_addr=GEM_buffer2;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1276 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1277
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
1278 #if 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
1279 printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\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
1280 surface->w, surface->h,
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1281 pxy[0],pxy[1],pxy[2],pxy[3],
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1282 pxy[4],pxy[5],pxy[6],pxy[7]
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1283 );
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 593
diff changeset
1284 #endif
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1285
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1286 vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1287 }
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1288
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1289 #ifdef HAVE_OPENGL
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1290
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
1291 static void GEM_GL_SwapBuffers(_THIS)
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1292 {
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
1293 if (gl_ctx == NULL) {
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
1294 return;
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1295 }
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1296
989
475166d13b44 Factorize OSMesa OpenGL code for Atari drivers
Patrice Mandin <patmandin@gmail.com>
parents: 988
diff changeset
1297 gl_convert(this->screen);
984
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1298 GEM_FlipHWSurface(this, this->screen);
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1299 }
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1300
44fd54a0ae5f Add OSMesa OpenGL support to the Atari GEM video driver
Patrice Mandin <patmandin@gmail.com>
parents: 964
diff changeset
1301 #endif