Mercurial > sdl-ios-xcode
comparison src/video/gem/SDL_gemvideo.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 417f2af2bd52 |
children | cb0fd9cdd2a9 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
67 #define MAX(a,b) (((a)>(b)) ? (a) : (b)) | 67 #define MAX(a,b) (((a)>(b)) ? (a) : (b)) |
68 | 68 |
69 /* Variables */ | 69 /* Variables */ |
70 | 70 |
71 static unsigned char vdi_index[256] = { | 71 static unsigned char vdi_index[256] = { |
72 0, 2, 3, 6, 4, 7, 5, 8, | 72 0, 2, 3, 6, 4, 7, 5, 8, |
73 9, 10, 11, 14, 12, 15, 13, 255 | 73 9, 10, 11, 14, 12, 15, 13, 255 |
74 }; | 74 }; |
75 | 75 |
76 static const unsigned char empty_name[]=""; | 76 static const unsigned char empty_name[] = ""; |
77 | 77 |
78 /* Initialization/Query functions */ | 78 /* Initialization/Query functions */ |
79 static int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat); | 79 static int GEM_VideoInit(_THIS, SDL_PixelFormat * vformat); |
80 static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 80 static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat * format, |
81 static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 81 Uint32 flags); |
82 static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | 82 static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface * current, int width, |
83 int height, int bpp, Uint32 flags); | |
84 static int GEM_SetColors(_THIS, int firstcolor, int ncolors, | |
85 SDL_Color * colors); | |
83 static void GEM_VideoQuit(_THIS); | 86 static void GEM_VideoQuit(_THIS); |
84 | 87 |
85 /* Hardware surface functions */ | 88 /* Hardware surface functions */ |
86 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface); | 89 static int GEM_AllocHWSurface(_THIS, SDL_Surface * surface); |
87 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface); | 90 static int GEM_LockHWSurface(_THIS, SDL_Surface * surface); |
88 static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface); | 91 static int GEM_FlipHWSurface(_THIS, SDL_Surface * surface); |
89 static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface); | 92 static void GEM_UnlockHWSurface(_THIS, SDL_Surface * surface); |
90 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface); | 93 static void GEM_FreeHWSurface(_THIS, SDL_Surface * surface); |
91 static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects); | 94 static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects); |
92 #if 0 | 95 #if 0 |
93 static int GEM_ToggleFullScreen(_THIS, int on); | 96 static int GEM_ToggleFullScreen(_THIS, int on); |
94 #endif | 97 #endif |
95 | 98 |
96 /* Internal functions */ | 99 /* Internal functions */ |
107 static void GEM_GL_SwapBuffers(_THIS); | 110 static void GEM_GL_SwapBuffers(_THIS); |
108 #endif | 111 #endif |
109 | 112 |
110 /* GEM driver bootstrap functions */ | 113 /* GEM driver bootstrap functions */ |
111 | 114 |
112 static int GEM_Available(void) | 115 static int |
113 { | 116 GEM_Available(void) |
114 /* Test if AES available */ | 117 { |
115 if (appl_init() == -1) | 118 /* Test if AES available */ |
116 return 0; | 119 if (appl_init() == -1) |
117 | 120 return 0; |
118 appl_exit(); | 121 |
119 return 1; | 122 appl_exit(); |
120 } | 123 return 1; |
121 | 124 } |
122 static void GEM_DeleteDevice(SDL_VideoDevice *device) | 125 |
123 { | 126 static void |
124 SDL_free(device->hidden); | 127 GEM_DeleteDevice(SDL_VideoDevice * device) |
125 SDL_free(device); | 128 { |
126 } | 129 SDL_free(device->hidden); |
127 | 130 SDL_free(device); |
128 static SDL_VideoDevice *GEM_CreateDevice(int devindex) | 131 } |
129 { | 132 |
130 SDL_VideoDevice *device; | 133 static SDL_VideoDevice * |
131 int vectors_mask; | 134 GEM_CreateDevice(int devindex) |
132 unsigned long dummy; | 135 { |
133 | 136 SDL_VideoDevice *device; |
134 /* Initialize all variables that we clean on shutdown */ | 137 int vectors_mask; |
135 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 138 unsigned long dummy; |
136 if ( device ) { | 139 |
137 SDL_memset(device, 0, (sizeof *device)); | 140 /* Initialize all variables that we clean on shutdown */ |
138 device->hidden = (struct SDL_PrivateVideoData *) | 141 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); |
139 SDL_malloc((sizeof *device->hidden)); | 142 if (device) { |
140 device->gl_data = (struct SDL_PrivateGLData *) | 143 SDL_memset(device, 0, (sizeof *device)); |
141 SDL_malloc((sizeof *device->gl_data)); | 144 device->hidden = (struct SDL_PrivateVideoData *) |
142 } | 145 SDL_malloc((sizeof *device->hidden)); |
143 if ( (device == NULL) || (device->hidden == NULL) ) { | 146 device->gl_data = (struct SDL_PrivateGLData *) |
144 SDL_OutOfMemory(); | 147 SDL_malloc((sizeof *device->gl_data)); |
145 if ( device ) { | 148 } |
146 SDL_free(device); | 149 if ((device == NULL) || (device->hidden == NULL)) { |
147 } | 150 SDL_OutOfMemory(); |
148 return(0); | 151 if (device) { |
149 } | 152 SDL_free(device); |
150 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | 153 } |
151 SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); | 154 return (0); |
152 | 155 } |
153 /* Set the function pointers */ | 156 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
154 device->VideoInit = GEM_VideoInit; | 157 SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); |
155 device->ListModes = GEM_ListModes; | 158 |
156 device->SetVideoMode = GEM_SetVideoMode; | 159 /* Set the function pointers */ |
157 device->SetColors = GEM_SetColors; | 160 device->VideoInit = GEM_VideoInit; |
158 device->UpdateRects = NULL /*GEM_UpdateRects*/; | 161 device->ListModes = GEM_ListModes; |
159 device->VideoQuit = GEM_VideoQuit; | 162 device->SetVideoMode = GEM_SetVideoMode; |
160 device->AllocHWSurface = GEM_AllocHWSurface; | 163 device->SetColors = GEM_SetColors; |
161 device->LockHWSurface = GEM_LockHWSurface; | 164 device->UpdateRects = NULL /*GEM_UpdateRects */ ; |
162 device->UnlockHWSurface = GEM_UnlockHWSurface; | 165 device->VideoQuit = GEM_VideoQuit; |
163 device->FlipHWSurface = GEM_FlipHWSurface; | 166 device->AllocHWSurface = GEM_AllocHWSurface; |
164 device->FreeHWSurface = GEM_FreeHWSurface; | 167 device->LockHWSurface = GEM_LockHWSurface; |
165 device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/; | 168 device->UnlockHWSurface = GEM_UnlockHWSurface; |
166 | 169 device->FlipHWSurface = GEM_FlipHWSurface; |
167 /* Window manager */ | 170 device->FreeHWSurface = GEM_FreeHWSurface; |
168 device->SetCaption = GEM_SetCaption; | 171 device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen */ ; |
169 device->SetIcon = GEM_SetIcon; | 172 |
170 device->IconifyWindow = GEM_IconifyWindow; | 173 /* Window manager */ |
171 device->GrabInput = GEM_GrabInput; | 174 device->SetCaption = GEM_SetCaption; |
172 | 175 device->SetIcon = GEM_SetIcon; |
173 /* Events */ | 176 device->IconifyWindow = GEM_IconifyWindow; |
174 device->InitOSKeymap = GEM_InitOSKeymap; | 177 device->GrabInput = GEM_GrabInput; |
175 device->PumpEvents = GEM_PumpEvents; | 178 |
176 | 179 /* Events */ |
177 /* Mouse */ | 180 device->InitOSKeymap = GEM_InitOSKeymap; |
178 device->FreeWMCursor = GEM_FreeWMCursor; | 181 device->PumpEvents = GEM_PumpEvents; |
179 device->CreateWMCursor = GEM_CreateWMCursor; | 182 |
180 device->ShowWMCursor = GEM_ShowWMCursor; | 183 /* Mouse */ |
181 device->WarpWMCursor = NULL /*GEM_WarpWMCursor*/; | 184 device->FreeWMCursor = GEM_FreeWMCursor; |
182 device->CheckMouseMode = GEM_CheckMouseMode; | 185 device->CreateWMCursor = GEM_CreateWMCursor; |
186 device->ShowWMCursor = GEM_ShowWMCursor; | |
187 device->WarpWMCursor = NULL /*GEM_WarpWMCursor */ ; | |
188 device->CheckMouseMode = GEM_CheckMouseMode; | |
183 | 189 |
184 #if SDL_VIDEO_OPENGL | 190 #if SDL_VIDEO_OPENGL |
185 /* OpenGL functions */ | 191 /* OpenGL functions */ |
186 device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary; | 192 device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary; |
187 device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress; | 193 device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress; |
188 device->GL_GetAttribute = SDL_AtariGL_GetAttribute; | 194 device->GL_GetAttribute = SDL_AtariGL_GetAttribute; |
189 device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent; | 195 device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent; |
190 device->GL_SwapBuffers = GEM_GL_SwapBuffers; | 196 device->GL_SwapBuffers = GEM_GL_SwapBuffers; |
191 #endif | 197 #endif |
192 | 198 |
193 device->hidden->use_dev_mouse = | 199 device->hidden->use_dev_mouse = |
194 (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE; | 200 (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; |
195 | 201 |
196 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | 202 vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ |
197 if (!(device->hidden->use_dev_mouse)) { | 203 if (!(device->hidden->use_dev_mouse)) { |
198 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | 204 vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ |
199 } | 205 } |
200 if (Getcookie(C_MiNT, &dummy)==C_FOUND) { | 206 if (Getcookie(C_MiNT, &dummy) == C_FOUND) { |
201 vectors_mask = 0; | 207 vectors_mask = 0; |
202 } | 208 } |
203 | 209 |
204 SDL_AtariXbios_InstallVectors(vectors_mask); | 210 SDL_AtariXbios_InstallVectors(vectors_mask); |
205 | 211 |
206 device->free = GEM_DeleteDevice; | 212 device->free = GEM_DeleteDevice; |
207 | 213 |
208 return device; | 214 return device; |
209 } | 215 } |
210 | 216 |
211 VideoBootStrap GEM_bootstrap = { | 217 VideoBootStrap GEM_bootstrap = { |
212 GEM_VID_DRIVER_NAME, "Atari GEM video driver", | 218 GEM_VID_DRIVER_NAME, "Atari GEM video driver", |
213 GEM_Available, GEM_CreateDevice | 219 GEM_Available, GEM_CreateDevice |
214 }; | 220 }; |
215 | 221 |
216 static void VDI_ReadExtInfo(_THIS, short *work_out) | 222 static void |
217 { | 223 VDI_ReadExtInfo(_THIS, short *work_out) |
218 unsigned long EdDI_version; | 224 { |
219 unsigned long cookie_EdDI; | 225 unsigned long EdDI_version; |
220 Uint32 num_colours; | 226 unsigned long cookie_EdDI; |
221 Uint16 clut_type, num_bits; | 227 Uint32 num_colours; |
222 | 228 Uint16 clut_type, num_bits; |
223 /* Read EdDI informations */ | 229 |
224 if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) { | 230 /* Read EdDI informations */ |
225 return; | 231 if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) { |
226 } | 232 return; |
227 | 233 } |
228 EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI); | 234 |
229 | 235 EdDI_version = Atari_get_EdDI_version((void *) cookie_EdDI); |
230 vq_scrninfo(VDI_handle, work_out); | 236 |
231 | 237 vq_scrninfo(VDI_handle, work_out); |
232 VDI_format = work_out[0]; | 238 |
233 clut_type = work_out[1]; | 239 VDI_format = work_out[0]; |
234 num_bits = work_out[2]; | 240 clut_type = work_out[1]; |
235 num_colours = *((Uint32 *) &work_out[3]); | 241 num_bits = work_out[2]; |
236 | 242 num_colours = *((Uint32 *) & work_out[3]); |
237 /* With EdDI>=1.1, we can have screen pitch, address and format | 243 |
238 * so we can directly write to screen without using vro_cpyfm | 244 /* With EdDI>=1.1, we can have screen pitch, address and format |
239 */ | 245 * so we can directly write to screen without using vro_cpyfm |
240 if (EdDI_version >= EDDI_11) { | 246 */ |
241 VDI_pitch = work_out[5]; | 247 if (EdDI_version >= EDDI_11) { |
242 VDI_screen = (void *) *((unsigned long *) &work_out[6]); | 248 VDI_pitch = work_out[5]; |
243 } | 249 VDI_screen = (void *) *((unsigned long *) &work_out[6]); |
244 | 250 } |
245 switch(clut_type) { | 251 |
246 case VDI_CLUT_HARDWARE: | 252 switch (clut_type) { |
247 { | 253 case VDI_CLUT_HARDWARE: |
248 int i; | 254 { |
249 Uint16 *tmp_p; | 255 int i; |
250 | 256 Uint16 *tmp_p; |
251 tmp_p = (Uint16 *)&work_out[16]; | 257 |
252 | 258 tmp_p = (Uint16 *) & work_out[16]; |
253 for (i=0;i<256;i++) { | 259 |
254 vdi_index[*tmp_p++] = i; | 260 for (i = 0; i < 256; i++) { |
255 } | 261 vdi_index[*tmp_p++] = i; |
256 } | 262 } |
257 break; | 263 } |
258 case VDI_CLUT_SOFTWARE: | 264 break; |
259 { | 265 case VDI_CLUT_SOFTWARE: |
260 int component; /* red, green, blue, alpha, overlay */ | 266 { |
261 int num_bit; | 267 int component; /* red, green, blue, alpha, overlay */ |
262 unsigned short *tmp_p; | 268 int num_bit; |
263 | 269 unsigned short *tmp_p; |
264 /* We can build masks with info here */ | 270 |
265 tmp_p = (unsigned short *) &work_out[16]; | 271 /* We can build masks with info here */ |
266 for (component=0;component<5;component++) { | 272 tmp_p = (unsigned short *) &work_out[16]; |
267 for (num_bit=0;num_bit<16;num_bit++) { | 273 for (component = 0; component < 5; component++) { |
268 unsigned short valeur; | 274 for (num_bit = 0; num_bit < 16; num_bit++) { |
269 | 275 unsigned short valeur; |
270 valeur = *tmp_p++; | 276 |
271 | 277 valeur = *tmp_p++; |
272 if (valeur == 0xffff) { | 278 |
273 continue; | 279 if (valeur == 0xffff) { |
274 } | 280 continue; |
275 | 281 } |
276 switch(component) { | 282 |
277 case 0: | 283 switch (component) { |
278 VDI_redmask |= 1<< valeur; | 284 case 0: |
279 break; | 285 VDI_redmask |= 1 << valeur; |
280 case 1: | 286 break; |
281 VDI_greenmask |= 1<< valeur; | 287 case 1: |
282 break; | 288 VDI_greenmask |= 1 << valeur; |
283 case 2: | 289 break; |
284 VDI_bluemask |= 1<< valeur; | 290 case 2: |
285 break; | 291 VDI_bluemask |= 1 << valeur; |
286 case 3: | 292 break; |
287 VDI_alphamask |= 1<< valeur; | 293 case 3: |
288 break; | 294 VDI_alphamask |= 1 << valeur; |
289 } | 295 break; |
290 } | 296 } |
291 } | 297 } |
292 } | 298 } |
293 | 299 } |
294 /* Remove lower green bits for Intel endian screen */ | 300 |
295 if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) { | 301 /* Remove lower green bits for Intel endian screen */ |
296 VDI_greenmask &= ~(7<<13); | 302 if ((VDI_greenmask == ((7 << 13) | 3)) |
297 } | 303 || (VDI_greenmask == ((7 << 13) | 7))) { |
298 break; | 304 VDI_greenmask &= ~(7 << 13); |
299 case VDI_CLUT_NONE: | 305 } |
300 break; | 306 break; |
301 } | 307 case VDI_CLUT_NONE: |
302 } | 308 break; |
303 | 309 } |
304 int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) | 310 } |
305 { | 311 |
306 int i, menubar_size; | 312 int |
307 short work_in[12], work_out[272], dummy; | 313 GEM_VideoInit(_THIS, SDL_PixelFormat * vformat) |
308 | 314 { |
309 /* Open AES (Application Environment Services) */ | 315 int i, menubar_size; |
310 if (appl_init() == -1) { | 316 short work_in[12], work_out[272], dummy; |
311 fprintf(stderr,"Can not open AES\n"); | 317 |
312 return 1; | 318 /* Open AES (Application Environment Services) */ |
313 } | 319 if (appl_init() == -1) { |
314 | 320 fprintf(stderr, "Can not open AES\n"); |
315 /* Read version and features */ | 321 return 1; |
316 GEM_version = aes_global[0]; | 322 } |
317 if (GEM_version >= 0x0410) { | 323 |
318 short ap_gout[4], errorcode; | 324 /* Read version and features */ |
319 | 325 GEM_version = aes_global[0]; |
320 GEM_wfeatures=0; | 326 if (GEM_version >= 0x0410) { |
321 errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]); | 327 short ap_gout[4], errorcode; |
322 | 328 |
323 if (errorcode==0) { | 329 GEM_wfeatures = 0; |
324 GEM_wfeatures=ap_gout[0]; | 330 errorcode = |
325 } | 331 appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], |
326 } | 332 &ap_gout[3]); |
327 | 333 |
328 /* Ask VDI physical workstation handle opened by AES */ | 334 if (errorcode == 0) { |
329 VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); | 335 GEM_wfeatures = ap_gout[0]; |
330 if (VDI_handle<1) { | 336 } |
331 fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle); | 337 } |
332 return 1; | 338 |
333 } | 339 /* Ask VDI physical workstation handle opened by AES */ |
334 | 340 VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); |
335 /* Open virtual VDI workstation */ | 341 if (VDI_handle < 1) { |
336 work_in[0]=Getrez()+2; | 342 fprintf(stderr, "Wrong VDI handle %d returned by AES\n", VDI_handle); |
337 for(i = 1; i < 10; i++) | 343 return 1; |
338 work_in[i] = 1; | 344 } |
339 work_in[10] = 2; | 345 |
340 | 346 /* Open virtual VDI workstation */ |
341 v_opnvwk(work_in, &VDI_handle, work_out); | 347 work_in[0] = Getrez() + 2; |
342 if (VDI_handle == 0) { | 348 for (i = 1; i < 10; i++) |
343 fprintf(stderr,"Can not open VDI virtual workstation\n"); | 349 work_in[i] = 1; |
344 return 1; | 350 work_in[10] = 2; |
345 } | 351 |
346 | 352 v_opnvwk(work_in, &VDI_handle, work_out); |
347 /* Read fullscreen size */ | 353 if (VDI_handle == 0) { |
348 VDI_w = work_out[0] + 1; | 354 fprintf(stderr, "Can not open VDI virtual workstation\n"); |
349 VDI_h = work_out[1] + 1; | 355 return 1; |
350 | 356 } |
351 /* Read desktop size and position */ | 357 |
352 if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) { | 358 /* Read fullscreen size */ |
353 fprintf(stderr,"Can not read desktop properties\n"); | 359 VDI_w = work_out[0] + 1; |
354 return 1; | 360 VDI_h = work_out[1] + 1; |
355 } | 361 |
356 | 362 /* Read desktop size and position */ |
357 /* Read bit depth */ | 363 if (!wind_get |
358 vq_extnd(VDI_handle, 1, work_out); | 364 (DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, |
359 VDI_bpp = work_out[4]; | 365 &GEM_desk_h)) { |
360 VDI_oldnumcolors=0; | 366 fprintf(stderr, "Can not read desktop properties\n"); |
361 | 367 return 1; |
362 switch(VDI_bpp) { | 368 } |
363 case 8: | 369 |
364 VDI_pixelsize=1; | 370 /* Read bit depth */ |
365 break; | 371 vq_extnd(VDI_handle, 1, work_out); |
366 case 15: | 372 VDI_bpp = work_out[4]; |
367 case 16: | 373 VDI_oldnumcolors = 0; |
368 VDI_pixelsize=2; | 374 |
369 break; | 375 switch (VDI_bpp) { |
370 case 24: | 376 case 8: |
371 VDI_pixelsize=3; | 377 VDI_pixelsize = 1; |
372 break; | 378 break; |
373 case 32: | 379 case 15: |
374 VDI_pixelsize=4; | 380 case 16: |
375 break; | 381 VDI_pixelsize = 2; |
376 default: | 382 break; |
377 fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp); | 383 case 24: |
378 return 1; | 384 VDI_pixelsize = 3; |
379 } | 385 break; |
380 | 386 case 32: |
381 /* Setup hardware -> VDI palette mapping */ | 387 VDI_pixelsize = 4; |
382 for(i = 16; i < 255; i++) { | 388 break; |
383 vdi_index[i] = i; | 389 default: |
384 } | 390 fprintf(stderr, "%d bits colour depth not supported\n", VDI_bpp); |
385 vdi_index[255] = 1; | 391 return 1; |
386 | 392 } |
387 /* Save current palette */ | 393 |
388 if (VDI_bpp>8) { | 394 /* Setup hardware -> VDI palette mapping */ |
389 VDI_oldnumcolors=1<<8; | 395 for (i = 16; i < 255; i++) { |
390 } else { | 396 vdi_index[i] = i; |
391 VDI_oldnumcolors=1<<VDI_bpp; | 397 } |
392 } | 398 vdi_index[255] = 1; |
393 | 399 |
394 for(i = 0; i < VDI_oldnumcolors; i++) { | 400 /* Save current palette */ |
395 short rgb[3]; | 401 if (VDI_bpp > 8) { |
396 | 402 VDI_oldnumcolors = 1 << 8; |
397 vq_color(VDI_handle, i, 0, rgb); | 403 } else { |
398 | 404 VDI_oldnumcolors = 1 << VDI_bpp; |
399 VDI_oldpalette[i][0] = rgb[0]; | 405 } |
400 VDI_oldpalette[i][1] = rgb[1]; | 406 |
401 VDI_oldpalette[i][2] = rgb[2]; | 407 for (i = 0; i < VDI_oldnumcolors; i++) { |
402 } | 408 short rgb[3]; |
403 VDI_setpalette = GEM_SetNewPalette; | 409 |
404 SDL_memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette)); | 410 vq_color(VDI_handle, i, 0, rgb); |
405 | 411 |
406 /* Setup screen info */ | 412 VDI_oldpalette[i][0] = rgb[0]; |
407 GEM_title_name = empty_name; | 413 VDI_oldpalette[i][1] = rgb[1]; |
408 GEM_icon_name = empty_name; | 414 VDI_oldpalette[i][2] = rgb[2]; |
409 | 415 } |
410 GEM_handle = -1; | 416 VDI_setpalette = GEM_SetNewPalette; |
411 GEM_locked = SDL_FALSE; | 417 SDL_memcpy(VDI_curpalette, VDI_oldpalette, sizeof(VDI_curpalette)); |
412 GEM_win_fulled = SDL_FALSE; | 418 |
413 GEM_fullscreen = SDL_FALSE; | 419 /* Setup screen info */ |
414 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers are setup */ | 420 GEM_title_name = empty_name; |
415 | 421 GEM_icon_name = empty_name; |
416 VDI_screen = NULL; | 422 |
417 VDI_pitch = VDI_w * VDI_pixelsize; | 423 GEM_handle = -1; |
418 VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK); | 424 GEM_locked = SDL_FALSE; |
419 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; | 425 GEM_win_fulled = SDL_FALSE; |
420 VDI_ReadExtInfo(this, work_out); | 426 GEM_fullscreen = SDL_FALSE; |
427 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers are setup */ | |
428 | |
429 VDI_screen = NULL; | |
430 VDI_pitch = VDI_w * VDI_pixelsize; | |
431 VDI_format = ((VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK); | |
432 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; | |
433 VDI_ReadExtInfo(this, work_out); | |
421 | 434 |
422 #ifdef DEBUG_VIDEO_GEM | 435 #ifdef DEBUG_VIDEO_GEM |
423 printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch); | 436 printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, |
424 printf("sdl:video:gem: format=%d\n", VDI_format); | 437 VDI_pitch); |
425 printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", | 438 printf("sdl:video:gem: format=%d\n", VDI_format); |
426 VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask | 439 printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", |
427 ); | 440 VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask); |
428 #endif | 441 #endif |
429 | 442 |
430 /* Setup destination mfdb */ | 443 /* Setup destination mfdb */ |
431 VDI_dst_mfdb.fd_addr = NULL; | 444 VDI_dst_mfdb.fd_addr = NULL; |
432 | 445 |
433 /* Determine the current screen size */ | 446 /* Determine the current screen size */ |
434 this->info.current_w = VDI_w; | 447 this->info.current_w = VDI_w; |
435 this->info.current_h = VDI_h; | 448 this->info.current_h = VDI_h; |
436 | 449 |
437 /* Determine the screen depth */ | 450 /* Determine the screen depth */ |
438 /* we change this during the SDL_SetVideoMode implementation... */ | 451 /* we change this during the SDL_SetVideoMode implementation... */ |
439 vformat->BitsPerPixel = VDI_bpp; | 452 vformat->BitsPerPixel = VDI_bpp; |
440 | 453 |
441 /* Set mouse cursor to arrow */ | 454 /* Set mouse cursor to arrow */ |
442 graf_mouse(ARROW, NULL); | 455 graf_mouse(ARROW, NULL); |
443 GEM_cursor = NULL; | 456 |
444 | 457 /* Init chunky to planar routine */ |
445 /* Init chunky to planar routine */ | 458 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; |
446 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; | 459 |
447 | 460 /* Setup VDI fill functions */ |
448 /* Setup VDI fill functions */ | 461 vsf_color(VDI_handle, 0); |
449 vsf_color(VDI_handle,0); | 462 vsf_interior(VDI_handle, 1); |
450 vsf_interior(VDI_handle,1); | 463 vsf_perimeter(VDI_handle, 0); |
451 vsf_perimeter(VDI_handle,0); | 464 |
452 | 465 /* Menu bar save buffer */ |
453 /* Menu bar save buffer */ | 466 menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize; |
454 menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize; | 467 GEM_menubar = Atari_SysMalloc(menubar_size, MX_PREFTTRAM); |
455 GEM_menubar=Atari_SysMalloc(menubar_size,MX_PREFTTRAM); | 468 |
456 | 469 /* Fill video modes list */ |
457 /* Fill video modes list */ | 470 SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect)); |
458 SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect)); | 471 SDL_modelist[0]->x = 0; |
459 SDL_modelist[0]->x = 0; | 472 SDL_modelist[0]->y = 0; |
460 SDL_modelist[0]->y = 0; | 473 SDL_modelist[0]->w = VDI_w; |
461 SDL_modelist[0]->w = VDI_w; | 474 SDL_modelist[0]->h = VDI_h; |
462 SDL_modelist[0]->h = VDI_h; | 475 |
463 | 476 SDL_modelist[1] = NULL; |
464 SDL_modelist[1] = NULL; | |
465 | 477 |
466 #if SDL_VIDEO_OPENGL | 478 #if SDL_VIDEO_OPENGL |
467 SDL_AtariGL_InitPointers(this); | 479 SDL_AtariGL_InitPointers(this); |
468 #endif | 480 #endif |
469 | 481 |
470 /* We're done! */ | 482 /* We're done! */ |
471 return(0); | 483 return (0); |
472 } | 484 } |
473 | 485 |
474 SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 486 SDL_Rect ** |
475 { | 487 GEM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
476 if (format->BitsPerPixel != VDI_bpp) { | 488 { |
477 return ((SDL_Rect **)NULL); | 489 if (format->BitsPerPixel != VDI_bpp) { |
478 } | 490 return ((SDL_Rect **) NULL); |
479 | 491 } |
480 if (flags & SDL_FULLSCREEN) { | 492 |
481 return (SDL_modelist); | 493 if (flags & SDL_FULLSCREEN) { |
482 } | 494 return (SDL_modelist); |
483 | 495 } |
484 return((SDL_Rect **)-1); | 496 |
485 } | 497 return ((SDL_Rect **) - 1); |
486 | 498 } |
487 static void GEM_FreeBuffers(_THIS) | 499 |
488 { | 500 static void |
489 /* Release buffer */ | 501 GEM_FreeBuffers(_THIS) |
490 if ( GEM_buffer2 ) { | 502 { |
491 Mfree( GEM_buffer2 ); | 503 /* Release buffer */ |
492 GEM_buffer2=NULL; | 504 if (GEM_buffer2) { |
493 } | 505 Mfree(GEM_buffer2); |
494 | 506 GEM_buffer2 = NULL; |
495 if ( GEM_buffer1 ) { | 507 } |
496 Mfree( GEM_buffer1 ); | 508 |
497 GEM_buffer1=NULL; | 509 if (GEM_buffer1) { |
498 } | 510 Mfree(GEM_buffer1); |
499 } | 511 GEM_buffer1 = NULL; |
500 | 512 } |
501 static void GEM_ClearRect(_THIS, short *rect) | 513 } |
502 { | 514 |
503 short oldrgb[3], rgb[3]={0,0,0}; | 515 static void |
504 | 516 GEM_ClearRect(_THIS, short *rect) |
505 vq_color(VDI_handle, vdi_index[0], 0, oldrgb); | 517 { |
506 vs_color(VDI_handle, vdi_index[0], rgb); | 518 short oldrgb[3], rgb[3] = { 0, 0, 0 }; |
507 | 519 |
508 vsf_color(VDI_handle,0); | 520 vq_color(VDI_handle, vdi_index[0], 0, oldrgb); |
509 vsf_interior(VDI_handle,1); | 521 vs_color(VDI_handle, vdi_index[0], rgb); |
510 vsf_perimeter(VDI_handle,0); | 522 |
511 v_bar(VDI_handle, rect); | 523 vsf_color(VDI_handle, 0); |
512 | 524 vsf_interior(VDI_handle, 1); |
513 vs_color(VDI_handle, vdi_index[0], oldrgb); | 525 vsf_perimeter(VDI_handle, 0); |
514 } | 526 v_bar(VDI_handle, rect); |
515 | 527 |
516 static void GEM_ClearScreen(_THIS) | 528 vs_color(VDI_handle, vdi_index[0], oldrgb); |
517 { | 529 } |
518 short pxy[4]; | 530 |
519 | 531 static void |
520 v_hide_c(VDI_handle); | 532 GEM_ClearScreen(_THIS) |
521 | 533 { |
522 pxy[0] = pxy[1] = 0; | 534 short pxy[4]; |
523 pxy[2] = VDI_w - 1; | 535 |
524 pxy[3] = VDI_h - 1; | 536 v_hide_c(VDI_handle); |
525 GEM_ClearRect(this, pxy); | 537 |
526 | 538 pxy[0] = pxy[1] = 0; |
527 v_show_c(VDI_handle, 1); | 539 pxy[2] = VDI_w - 1; |
528 } | 540 pxy[3] = VDI_h - 1; |
529 | 541 GEM_ClearRect(this, pxy); |
530 static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]) | 542 |
531 { | 543 v_show_c(VDI_handle, 1); |
532 int i; | 544 } |
533 short rgb[3]; | 545 |
534 | 546 static void |
535 if (VDI_oldnumcolors==0) | 547 GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]) |
536 return; | 548 { |
537 | 549 int i; |
538 for(i = 0; i < VDI_oldnumcolors; i++) { | 550 short rgb[3]; |
539 rgb[0] = newpal[i][0]; | 551 |
540 rgb[1] = newpal[i][1]; | 552 if (VDI_oldnumcolors == 0) |
541 rgb[2] = newpal[i][2]; | 553 return; |
542 | 554 |
543 vs_color(VDI_handle, i, rgb); | 555 for (i = 0; i < VDI_oldnumcolors; i++) { |
544 } | 556 rgb[0] = newpal[i][0]; |
545 } | 557 rgb[1] = newpal[i][1]; |
546 | 558 rgb[2] = newpal[i][2]; |
547 static void GEM_LockScreen(_THIS) | 559 |
548 { | 560 vs_color(VDI_handle, i, rgb); |
549 if (!GEM_locked) { | 561 } |
550 /* Lock AES */ | 562 } |
551 wind_update(BEG_UPDATE); | 563 |
552 wind_update(BEG_MCTRL); | 564 static void |
553 /* Reserve memory space, used to be sure of compatibility */ | 565 GEM_LockScreen(_THIS) |
554 form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h); | 566 { |
555 | 567 if (!GEM_locked) { |
556 /* Save menu bar */ | 568 /* Lock AES */ |
557 if (GEM_menubar) { | 569 wind_update(BEG_UPDATE); |
558 MFDB mfdb_src; | 570 wind_update(BEG_MCTRL); |
559 short blitcoords[8]; | 571 /* Reserve memory space, used to be sure of compatibility */ |
560 | 572 form_dial(FMD_START, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); |
561 mfdb_src.fd_addr=GEM_menubar; | 573 |
562 mfdb_src.fd_w=GEM_desk_w; | 574 /* Save menu bar */ |
563 mfdb_src.fd_h=GEM_desk_y; | 575 if (GEM_menubar) { |
564 mfdb_src.fd_wdwidth=GEM_desk_w>>4; | 576 MFDB mfdb_src; |
565 mfdb_src.fd_nplanes=VDI_bpp; | 577 short blitcoords[8]; |
566 mfdb_src.fd_stand= | 578 |
567 mfdb_src.fd_r1= | 579 mfdb_src.fd_addr = GEM_menubar; |
568 mfdb_src.fd_r2= | 580 mfdb_src.fd_w = GEM_desk_w; |
569 mfdb_src.fd_r3= 0; | 581 mfdb_src.fd_h = GEM_desk_y; |
570 | 582 mfdb_src.fd_wdwidth = GEM_desk_w >> 4; |
571 blitcoords[0] = blitcoords[4] = 0; | 583 mfdb_src.fd_nplanes = VDI_bpp; |
572 blitcoords[1] = blitcoords[5] = 0; | 584 mfdb_src.fd_stand = |
573 blitcoords[2] = blitcoords[6] = GEM_desk_w-1; | 585 mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0; |
574 blitcoords[3] = blitcoords[7] = GEM_desk_y-1; | 586 |
575 | 587 blitcoords[0] = blitcoords[4] = 0; |
576 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb, &mfdb_src); | 588 blitcoords[1] = blitcoords[5] = 0; |
577 } | 589 blitcoords[2] = blitcoords[6] = GEM_desk_w - 1; |
578 | 590 blitcoords[3] = blitcoords[7] = GEM_desk_y - 1; |
579 GEM_locked=SDL_TRUE; | 591 |
580 } | 592 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb, |
581 } | 593 &mfdb_src); |
582 | 594 } |
583 static void GEM_UnlockScreen(_THIS) | 595 |
584 { | 596 GEM_locked = SDL_TRUE; |
585 if (GEM_locked) { | 597 } |
586 /* Restore menu bar */ | 598 } |
587 if (GEM_menubar) { | 599 |
588 MFDB mfdb_src; | 600 static void |
589 short blitcoords[8]; | 601 GEM_UnlockScreen(_THIS) |
590 | 602 { |
591 mfdb_src.fd_addr=GEM_menubar; | 603 if (GEM_locked) { |
592 mfdb_src.fd_w=GEM_desk_w; | 604 /* Restore menu bar */ |
593 mfdb_src.fd_h=GEM_desk_y; | 605 if (GEM_menubar) { |
594 mfdb_src.fd_wdwidth=GEM_desk_w>>4; | 606 MFDB mfdb_src; |
595 mfdb_src.fd_nplanes=VDI_bpp; | 607 short blitcoords[8]; |
596 mfdb_src.fd_stand= | 608 |
597 mfdb_src.fd_r1= | 609 mfdb_src.fd_addr = GEM_menubar; |
598 mfdb_src.fd_r2= | 610 mfdb_src.fd_w = GEM_desk_w; |
599 mfdb_src.fd_r3= 0; | 611 mfdb_src.fd_h = GEM_desk_y; |
600 | 612 mfdb_src.fd_wdwidth = GEM_desk_w >> 4; |
601 blitcoords[0] = blitcoords[4] = 0; | 613 mfdb_src.fd_nplanes = VDI_bpp; |
602 blitcoords[1] = blitcoords[5] = 0; | 614 mfdb_src.fd_stand = |
603 blitcoords[2] = blitcoords[6] = GEM_desk_w-1; | 615 mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0; |
604 blitcoords[3] = blitcoords[7] = GEM_desk_y-1; | 616 |
605 | 617 blitcoords[0] = blitcoords[4] = 0; |
606 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | 618 blitcoords[1] = blitcoords[5] = 0; |
607 } | 619 blitcoords[2] = blitcoords[6] = GEM_desk_w - 1; |
608 | 620 blitcoords[3] = blitcoords[7] = GEM_desk_y - 1; |
609 /* Restore screen memory, and send REDRAW to all apps */ | 621 |
610 form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h); | 622 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, |
611 /* Unlock AES */ | 623 &VDI_dst_mfdb); |
612 wind_update(END_MCTRL); | 624 } |
613 wind_update(END_UPDATE); | 625 |
614 | 626 /* Restore screen memory, and send REDRAW to all apps */ |
615 GEM_locked=SDL_FALSE; | 627 form_dial(FMD_FINISH, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); |
616 } | 628 /* Unlock AES */ |
617 } | 629 wind_update(END_MCTRL); |
618 | 630 wind_update(END_UPDATE); |
619 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, | 631 |
620 int width, int height, int bpp, Uint32 flags) | 632 GEM_locked = SDL_FALSE; |
621 { | 633 } |
622 int maxwidth, maxheight; | 634 } |
623 Uint32 modeflags, screensize; | 635 |
624 SDL_bool use_shadow1, use_shadow2; | 636 SDL_Surface * |
625 | 637 GEM_SetVideoMode(_THIS, SDL_Surface * current, |
626 /*--- Verify if asked mode can be used ---*/ | 638 int width, int height, int bpp, Uint32 flags) |
627 if (flags & SDL_FULLSCREEN) { | 639 { |
628 maxwidth=VDI_w; | 640 int maxwidth, maxheight; |
629 maxheight=VDI_h; | 641 Uint32 modeflags, screensize; |
630 } else { | 642 SDL_bool use_shadow1, use_shadow2; |
631 /* Windowed mode */ | 643 |
632 maxwidth=GEM_desk_w; | 644 /*--- Verify if asked mode can be used ---*/ |
633 maxheight=GEM_desk_h; | 645 if (flags & SDL_FULLSCREEN) { |
634 } | 646 maxwidth = VDI_w; |
635 | 647 maxheight = VDI_h; |
636 /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */ | 648 } else { |
637 if ((width & 15) != 0) { | 649 /* Windowed mode */ |
638 width = (width | 15) +1; | 650 maxwidth = GEM_desk_w; |
639 } | 651 maxheight = GEM_desk_h; |
640 | 652 } |
641 if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) { | 653 |
642 SDL_SetError("Couldn't find requested mode in list"); | 654 /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */ |
643 return(NULL); | 655 if ((width & 15) != 0) { |
644 } | 656 width = (width | 15) + 1; |
645 | 657 } |
646 /*--- Allocate the new pixel format for the screen ---*/ | 658 |
647 if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) { | 659 if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) { |
648 SDL_SetError("Couldn't allocate new pixel format for requested mode"); | 660 SDL_SetError("Couldn't find requested mode in list"); |
649 return(NULL); | 661 return (NULL); |
650 } | 662 } |
651 | 663 |
652 screensize = width * height * VDI_pixelsize; | 664 /*--- Allocate the new pixel format for the screen ---*/ |
665 if (!SDL_ReallocFormat | |
666 (current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, | |
667 VDI_alphamask)) { | |
668 SDL_SetError("Couldn't allocate new pixel format for requested mode"); | |
669 return (NULL); | |
670 } | |
671 | |
672 screensize = width * height * VDI_pixelsize; | |
653 | 673 |
654 #ifdef DEBUG_VIDEO_GEM | 674 #ifdef DEBUG_VIDEO_GEM |
655 printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize); | 675 printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, |
656 #endif | 676 bpp, screensize); |
657 | 677 #endif |
658 /*--- Allocate shadow buffers if needed, and conversion operations ---*/ | 678 |
659 GEM_FreeBuffers(this); | 679 /*--- Allocate shadow buffers if needed, and conversion operations ---*/ |
660 | 680 GEM_FreeBuffers(this); |
661 GEM_bufops=0; | 681 |
662 use_shadow1=use_shadow2=SDL_FALSE; | 682 GEM_bufops = 0; |
663 if (VDI_screen && (flags & SDL_FULLSCREEN)) { | 683 use_shadow1 = use_shadow2 = SDL_FALSE; |
664 if (VDI_format==VDI_FORMAT_INTER) { | 684 if (VDI_screen && (flags & SDL_FULLSCREEN)) { |
665 use_shadow1=SDL_TRUE; | 685 if (VDI_format == VDI_FORMAT_INTER) { |
666 GEM_bufops = B2S_C2P_1TOS; | 686 use_shadow1 = SDL_TRUE; |
667 } | 687 GEM_bufops = B2S_C2P_1TOS; |
668 } else { | 688 } |
669 use_shadow1=SDL_TRUE; | 689 } else { |
670 if (VDI_format==VDI_FORMAT_PACK) { | 690 use_shadow1 = SDL_TRUE; |
671 GEM_bufops = B2S_VROCPYFM_1TOS; | 691 if (VDI_format == VDI_FORMAT_PACK) { |
672 } else { | 692 GEM_bufops = B2S_VROCPYFM_1TOS; |
673 use_shadow2=SDL_TRUE; | 693 } else { |
674 GEM_bufops = B2S_C2P_1TO2|B2S_VROCPYFM_2TOS; | 694 use_shadow2 = SDL_TRUE; |
675 } | 695 GEM_bufops = B2S_C2P_1TO2 | B2S_VROCPYFM_2TOS; |
676 } | 696 } |
677 | 697 } |
678 if (use_shadow1) { | 698 |
679 GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM); | 699 if (use_shadow1) { |
680 if (GEM_buffer1==NULL) { | 700 GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM); |
681 SDL_SetError("Can not allocate %d KB for frame buffer", screensize>>10); | 701 if (GEM_buffer1 == NULL) { |
682 return NULL; | 702 SDL_SetError("Can not allocate %d KB for frame buffer", |
683 } | 703 screensize >> 10); |
684 SDL_memset(GEM_buffer1, 0, screensize); | 704 return NULL; |
705 } | |
706 SDL_memset(GEM_buffer1, 0, screensize); | |
685 #ifdef DEBUG_VIDEO_GEM | 707 #ifdef DEBUG_VIDEO_GEM |
686 printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); | 708 printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); |
687 #endif | 709 #endif |
688 } | 710 } |
689 | 711 |
690 if (use_shadow2) { | 712 if (use_shadow2) { |
691 GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM); | 713 GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM); |
692 if (GEM_buffer2==NULL) { | 714 if (GEM_buffer2 == NULL) { |
693 SDL_SetError("Can not allocate %d KB for shadow buffer", screensize>>10); | 715 SDL_SetError("Can not allocate %d KB for shadow buffer", |
694 return NULL; | 716 screensize >> 10); |
695 } | 717 return NULL; |
696 SDL_memset(GEM_buffer2, 0, screensize); | 718 } |
719 SDL_memset(GEM_buffer2, 0, screensize); | |
697 #ifdef DEBUG_VIDEO_GEM | 720 #ifdef DEBUG_VIDEO_GEM |
698 printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); | 721 printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); |
699 #endif | 722 #endif |
700 } | 723 } |
701 | 724 |
702 /*--- Initialize screen ---*/ | 725 /*--- Initialize screen ---*/ |
703 modeflags = SDL_PREALLOC; | 726 modeflags = SDL_PREALLOC; |
704 if (VDI_bpp == 8) { | 727 if (VDI_bpp == 8) { |
705 modeflags |= SDL_HWPALETTE; | 728 modeflags |= SDL_HWPALETTE; |
706 } | 729 } |
707 | 730 |
708 if (flags & SDL_FULLSCREEN) { | 731 if (flags & SDL_FULLSCREEN) { |
709 GEM_LockScreen(this); | 732 GEM_LockScreen(this); |
710 | 733 |
711 GEM_ClearScreen(this); | 734 GEM_ClearScreen(this); |
712 | 735 |
713 modeflags |= SDL_FULLSCREEN; | 736 modeflags |= SDL_FULLSCREEN; |
714 if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow1) { | 737 if (VDI_screen && (VDI_format == VDI_FORMAT_PACK) && !use_shadow1) { |
715 modeflags |= SDL_HWSURFACE; | 738 modeflags |= SDL_HWSURFACE; |
716 } else { | 739 } else { |
717 modeflags |= SDL_SWSURFACE; | 740 modeflags |= SDL_SWSURFACE; |
718 } | 741 } |
719 | 742 |
720 GEM_fullscreen = SDL_TRUE; | 743 GEM_fullscreen = SDL_TRUE; |
721 } else { | 744 } else { |
722 int old_win_type; | 745 int old_win_type; |
723 short x2,y2,w2,h2; | 746 short x2, y2, w2, h2; |
724 | 747 |
725 GEM_UnlockScreen(this); | 748 GEM_UnlockScreen(this); |
726 | 749 |
727 /* Set window gadgets */ | 750 /* Set window gadgets */ |
728 old_win_type = GEM_win_type; | 751 old_win_type = GEM_win_type; |
729 if (!(flags & SDL_NOFRAME)) { | 752 if (!(flags & SDL_NOFRAME)) { |
730 GEM_win_type=NAME|MOVER|CLOSER|SMALLER; | 753 GEM_win_type = NAME | MOVER | CLOSER | SMALLER; |
731 if (flags & SDL_RESIZABLE) { | 754 if (flags & SDL_RESIZABLE) { |
732 GEM_win_type |= FULLER|SIZER; | 755 GEM_win_type |= FULLER | SIZER; |
733 modeflags |= SDL_RESIZABLE; | 756 modeflags |= SDL_RESIZABLE; |
734 } | 757 } |
735 } else { | 758 } else { |
736 GEM_win_type=0; | 759 GEM_win_type = 0; |
737 modeflags |= SDL_NOFRAME; | 760 modeflags |= SDL_NOFRAME; |
738 } | 761 } |
739 modeflags |= SDL_SWSURFACE; | 762 modeflags |= SDL_SWSURFACE; |
740 | 763 |
741 /* Recreate window ? only for different widget or non-created window */ | 764 /* Recreate window ? only for different widget or non-created window */ |
742 if ((old_win_type != GEM_win_type) || (GEM_handle < 0)) { | 765 if ((old_win_type != GEM_win_type) || (GEM_handle < 0)) { |
743 /* Calculate window size */ | 766 /* Calculate window size */ |
744 if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) { | 767 if (!wind_calc |
745 GEM_FreeBuffers(this); | 768 (WC_BORDER, GEM_win_type, 0, 0, width, height, &x2, &y2, |
746 SDL_SetError("Can not calculate window attributes"); | 769 &w2, &h2)) { |
747 return NULL; | 770 GEM_FreeBuffers(this); |
748 } | 771 SDL_SetError("Can not calculate window attributes"); |
749 | 772 return NULL; |
750 /* Center window */ | 773 } |
751 x2 = GEM_desk_x+((GEM_desk_w-w2)>>1); | 774 |
752 y2 = GEM_desk_y+((GEM_desk_h-h2)>>1); | 775 /* Center window */ |
753 | 776 x2 = GEM_desk_x + ((GEM_desk_w - w2) >> 1); |
754 /* Destroy existing window */ | 777 y2 = GEM_desk_y + ((GEM_desk_h - h2) >> 1); |
755 if (GEM_handle >= 0) { | 778 |
756 wind_close(GEM_handle); | 779 /* Destroy existing window */ |
757 wind_delete(GEM_handle); | 780 if (GEM_handle >= 0) { |
758 } | 781 wind_close(GEM_handle); |
759 | 782 wind_delete(GEM_handle); |
760 /* Create window */ | 783 } |
761 GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2); | 784 |
762 if (GEM_handle<0) { | 785 /* Create window */ |
763 GEM_FreeBuffers(this); | 786 GEM_handle = wind_create(GEM_win_type, x2, y2, w2, h2); |
764 SDL_SetError("Can not create window"); | 787 if (GEM_handle < 0) { |
765 return NULL; | 788 GEM_FreeBuffers(this); |
766 } | 789 SDL_SetError("Can not create window"); |
767 | 790 return NULL; |
791 } | |
768 #ifdef DEBUG_VIDEO_GEM | 792 #ifdef DEBUG_VIDEO_GEM |
769 printf("sdl:video:gem: handle=%d\n", GEM_handle); | 793 printf("sdl:video:gem: handle=%d\n", GEM_handle); |
770 #endif | 794 #endif |
771 | 795 |
772 /* Setup window name */ | 796 /* Setup window name */ |
773 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); | 797 wind_set(GEM_handle, WF_NAME, |
774 GEM_refresh_name = SDL_FALSE; | 798 (short) (((unsigned long) GEM_title_name) >> 16), |
775 | 799 (short) (((unsigned long) GEM_title_name) & 0xffff), |
776 /* Open the window */ | 800 0, 0); |
777 wind_open(GEM_handle,x2,y2,w2,h2); | 801 GEM_refresh_name = SDL_FALSE; |
778 } else { | 802 |
779 /* Resize window if needed, to fit asked video mode */ | 803 /* Open the window */ |
780 if (modeflags & SDL_RESIZABLE) { | 804 wind_open(GEM_handle, x2, y2, w2, h2); |
781 wind_get (GEM_handle, WF_WORKXYWH, &x2,&y2,&w2,&h2); | 805 } else { |
782 if ((w2&15)!=0) { | 806 /* Resize window if needed, to fit asked video mode */ |
783 w2=(w2|15)+1; | 807 if (modeflags & SDL_RESIZABLE) { |
784 } | 808 wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
785 if ((w2!=width) || (h2!=height)) { | 809 if ((w2 & 15) != 0) { |
786 if (wind_calc(WC_BORDER, GEM_win_type, x2,y2,width,height, &x2,&y2,&w2,&h2)) { | 810 w2 = (w2 | 15) + 1; |
787 wind_set (GEM_handle, WF_CURRXYWH, x2,y2,w2,h2); | 811 } |
788 } | 812 if ((w2 != width) || (h2 != height)) { |
789 } | 813 if (wind_calc |
790 } | 814 (WC_BORDER, GEM_win_type, x2, y2, width, |
791 } | 815 height, &x2, &y2, &w2, &h2)) { |
792 | 816 wind_set(GEM_handle, WF_CURRXYWH, x2, y2, w2, h2); |
793 GEM_fullscreen = SDL_FALSE; | 817 } |
794 } | 818 } |
795 | 819 } |
796 /* Set up the new mode framebuffer */ | 820 } |
797 current->w = width; | 821 |
798 current->h = height; | 822 GEM_fullscreen = SDL_FALSE; |
799 if (use_shadow1) { | 823 } |
800 current->pixels = GEM_buffer1; | 824 |
801 current->pitch = width * VDI_pixelsize; | 825 /* Set up the new mode framebuffer */ |
802 } else { | 826 current->w = width; |
803 current->pixels = VDI_screen; | 827 current->h = height; |
804 current->pitch = VDI_pitch; | 828 if (use_shadow1) { |
805 } | 829 current->pixels = GEM_buffer1; |
830 current->pitch = width * VDI_pixelsize; | |
831 } else { | |
832 current->pixels = VDI_screen; | |
833 current->pitch = VDI_pitch; | |
834 } | |
806 | 835 |
807 #if SDL_VIDEO_OPENGL | 836 #if SDL_VIDEO_OPENGL |
808 if (flags & SDL_OPENGL) { | 837 if (flags & SDL_INTERNALOPENGL) { |
809 if (!SDL_AtariGL_Init(this, current)) { | 838 if (!SDL_AtariGL_Init(this, current)) { |
810 GEM_FreeBuffers(this); | 839 GEM_FreeBuffers(this); |
811 SDL_SetError("Can not create OpenGL context"); | 840 SDL_SetError("Can not create OpenGL context"); |
812 return NULL; | 841 return NULL; |
813 } | 842 } |
814 | 843 |
815 modeflags |= SDL_OPENGL; | 844 modeflags |= SDL_INTERNALOPENGL; |
816 } | 845 } |
817 #endif | 846 #endif |
818 | 847 |
819 current->flags = modeflags; | 848 current->flags = modeflags; |
820 | 849 |
821 #ifdef DEBUG_VIDEO_GEM | 850 #ifdef DEBUG_VIDEO_GEM |
822 printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h); | 851 printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h); |
823 #endif | 852 #endif |
824 | 853 |
825 this->UpdateRects = GEM_UpdateRects; | 854 this->UpdateRects = GEM_UpdateRects; |
826 GEM_lock_redraw = SDL_FALSE; /* Enable redraw */ | 855 GEM_lock_redraw = SDL_FALSE; /* Enable redraw */ |
827 | 856 |
828 /* We're done */ | 857 /* We're done */ |
829 return(current); | 858 return (current); |
830 } | 859 } |
831 | 860 |
832 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) | 861 static int |
833 { | 862 GEM_AllocHWSurface(_THIS, SDL_Surface * surface) |
834 return -1; | 863 { |
835 } | 864 return -1; |
836 | 865 } |
837 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface) | 866 |
838 { | 867 static void |
839 return; | 868 GEM_FreeHWSurface(_THIS, SDL_Surface * surface) |
840 } | 869 { |
841 | 870 return; |
842 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface) | 871 } |
843 { | 872 |
844 return(0); | 873 static int |
845 } | 874 GEM_LockHWSurface(_THIS, SDL_Surface * surface) |
846 | 875 { |
847 static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface) | 876 return (0); |
848 { | 877 } |
849 return; | 878 |
850 } | 879 static void |
851 | 880 GEM_UnlockHWSurface(_THIS, SDL_Surface * surface) |
852 static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) | 881 { |
853 { | 882 return; |
854 SDL_Surface *surface; | 883 } |
855 int i, surf_width; | 884 |
856 | 885 static void |
857 surface = this->screen; | 886 GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect * rects) |
858 /* Need to be a multiple of 16 pixels */ | 887 { |
859 surf_width=surface->w; | 888 SDL_Surface *surface; |
860 if ((surf_width & 15) != 0) { | 889 int i, surf_width; |
861 surf_width = (surf_width | 15) + 1; | 890 |
862 } | 891 surface = this->screen; |
863 | 892 /* Need to be a multiple of 16 pixels */ |
864 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { | 893 surf_width = surface->w; |
865 void *destscr; | 894 if ((surf_width & 15) != 0) { |
866 int destpitch; | 895 surf_width = (surf_width | 15) + 1; |
867 | 896 } |
868 if (GEM_bufops & B2S_C2P_1TOS) { | 897 |
869 destscr = VDI_screen; | 898 if (GEM_bufops & (B2S_C2P_1TO2 | B2S_C2P_1TOS)) { |
870 destpitch = VDI_pitch; | 899 void *destscr; |
871 } else { | 900 int destpitch; |
872 destscr = GEM_buffer2; | 901 |
873 destpitch = surface->pitch; | 902 if (GEM_bufops & B2S_C2P_1TOS) { |
874 } | 903 destscr = VDI_screen; |
875 | 904 destpitch = VDI_pitch; |
876 for (i=0;i<numrects;i++) { | 905 } else { |
877 void *source,*destination; | 906 destscr = GEM_buffer2; |
878 int x1,x2; | 907 destpitch = surface->pitch; |
879 | 908 } |
880 x1 = rects[i].x & ~15; | 909 |
881 x2 = rects[i].x+rects[i].w; | 910 for (i = 0; i < numrects; i++) { |
882 if (x2 & 15) { | 911 void *source, *destination; |
883 x2 = (x2 | 15) +1; | 912 int x1, x2; |
884 } | 913 |
885 | 914 x1 = rects[i].x & ~15; |
886 source = surface->pixels; | 915 x2 = rects[i].x + rects[i].w; |
887 source += surface->pitch * rects[i].y; | 916 if (x2 & 15) { |
888 source += x1; | 917 x2 = (x2 | 15) + 1; |
889 | 918 } |
890 destination = destscr; | 919 |
891 destination += destpitch * rects[i].y; | 920 source = surface->pixels; |
892 destination += x1; | 921 source += surface->pitch * rects[i].y; |
893 | 922 source += x1; |
894 SDL_Atari_C2pConvert( | 923 |
895 source, destination, | 924 destination = destscr; |
896 x2-x1, rects[i].h, | 925 destination += destpitch * rects[i].y; |
897 SDL_FALSE, | 926 destination += x1; |
898 surface->pitch, destpitch | 927 |
899 ); | 928 SDL_Atari_C2pConvert(source, destination, |
900 } | 929 x2 - x1, rects[i].h, |
901 } | 930 SDL_FALSE, surface->pitch, destpitch); |
902 | 931 } |
903 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { | 932 } |
904 MFDB mfdb_src; | 933 |
905 short blitcoords[8]; | 934 if (GEM_bufops & (B2S_VROCPYFM_1TOS | B2S_VROCPYFM_2TOS)) { |
906 | 935 MFDB mfdb_src; |
907 mfdb_src.fd_addr=surface->pixels; | 936 short blitcoords[8]; |
908 mfdb_src.fd_w=surf_width; | 937 |
909 mfdb_src.fd_h=surface->h; | 938 mfdb_src.fd_addr = surface->pixels; |
910 mfdb_src.fd_wdwidth= (surface->pitch/VDI_pixelsize) >> 4; | 939 mfdb_src.fd_w = surf_width; |
911 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 940 mfdb_src.fd_h = surface->h; |
912 mfdb_src.fd_stand= | 941 mfdb_src.fd_wdwidth = (surface->pitch / VDI_pixelsize) >> 4; |
913 mfdb_src.fd_r1= | 942 mfdb_src.fd_nplanes = surface->format->BitsPerPixel; |
914 mfdb_src.fd_r2= | 943 mfdb_src.fd_stand = |
915 mfdb_src.fd_r3= 0; | 944 mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0; |
916 if (GEM_bufops & B2S_VROCPYFM_2TOS) { | 945 if (GEM_bufops & B2S_VROCPYFM_2TOS) { |
917 mfdb_src.fd_addr=GEM_buffer2; | 946 mfdb_src.fd_addr = GEM_buffer2; |
918 } | 947 } |
919 | 948 |
920 for ( i=0; i<numrects; ++i ) { | 949 for (i = 0; i < numrects; ++i) { |
921 blitcoords[0] = blitcoords[4] = rects[i].x; | 950 blitcoords[0] = blitcoords[4] = rects[i].x; |
922 blitcoords[1] = blitcoords[5] = rects[i].y; | 951 blitcoords[1] = blitcoords[5] = rects[i].y; |
923 blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1; | 952 blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1; |
924 blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1; | 953 blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1; |
925 | 954 |
926 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | 955 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, |
927 } | 956 &VDI_dst_mfdb); |
928 } | 957 } |
929 } | 958 } |
930 | 959 } |
931 static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects) | 960 |
932 { | 961 static void |
933 short pxy[4], wind_pxy[4]; | 962 GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect * rects) |
934 int i; | 963 { |
935 | 964 short pxy[4], wind_pxy[4]; |
936 if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { | 965 int i; |
937 return; | 966 |
938 } | 967 if (wind_get |
939 | 968 (GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], |
940 for ( i=0; i<numrects; ++i ) { | 969 &wind_pxy[3]) == 0) { |
941 pxy[0] = wind_pxy[0] + rects[i].x; | 970 return; |
942 pxy[1] = wind_pxy[1] + rects[i].y; | 971 } |
943 pxy[2] = rects[i].w; | 972 |
944 pxy[3] = rects[i].h; | 973 for (i = 0; i < numrects; ++i) { |
945 | 974 pxy[0] = wind_pxy[0] + rects[i].x; |
946 GEM_wind_redraw(this, GEM_handle, pxy); | 975 pxy[1] = wind_pxy[1] + rects[i].y; |
947 } | 976 pxy[2] = rects[i].w; |
948 } | 977 pxy[3] = rects[i].h; |
949 | 978 |
950 static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects) | 979 GEM_wind_redraw(this, GEM_handle, pxy); |
951 { | 980 } |
952 SDL_Surface *surface; | 981 } |
953 | 982 |
954 if (GEM_lock_redraw) { | 983 static void |
955 return; | 984 GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects) |
956 } | 985 { |
957 | 986 SDL_Surface *surface; |
958 surface = this->screen; | 987 |
959 | 988 if (GEM_lock_redraw) { |
960 if (surface->flags & SDL_FULLSCREEN) { | 989 return; |
961 GEM_UpdateRectsFullscreen(this, numrects, rects); | 990 } |
962 } else { | 991 |
963 GEM_UpdateRectsWindowed(this, numrects, rects); | 992 surface = this->screen; |
964 } | 993 |
965 } | 994 if (surface->flags & SDL_FULLSCREEN) { |
966 | 995 GEM_UpdateRectsFullscreen(this, numrects, rects); |
967 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) | 996 } else { |
968 { | 997 GEM_UpdateRectsWindowed(this, numrects, rects); |
969 int surf_width; | 998 } |
970 | 999 } |
971 /* Need to be a multiple of 16 pixels */ | 1000 |
972 surf_width=surface->w; | 1001 static int |
973 if ((surf_width & 15) != 0) { | 1002 GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface * surface) |
974 surf_width = (surf_width | 15) + 1; | 1003 { |
975 } | 1004 int surf_width; |
976 | 1005 |
977 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { | 1006 /* Need to be a multiple of 16 pixels */ |
978 void *destscr; | 1007 surf_width = surface->w; |
979 int destpitch; | 1008 if ((surf_width & 15) != 0) { |
980 | 1009 surf_width = (surf_width | 15) + 1; |
981 if (GEM_bufops & B2S_C2P_1TOS) { | 1010 } |
982 destscr = VDI_screen; | 1011 |
983 destpitch = VDI_pitch; | 1012 if (GEM_bufops & (B2S_C2P_1TO2 | B2S_C2P_1TOS)) { |
984 } else { | 1013 void *destscr; |
985 destscr = GEM_buffer2; | 1014 int destpitch; |
986 destpitch = surface->pitch; | 1015 |
987 } | 1016 if (GEM_bufops & B2S_C2P_1TOS) { |
988 | 1017 destscr = VDI_screen; |
989 SDL_Atari_C2pConvert( | 1018 destpitch = VDI_pitch; |
990 surface->pixels, destscr, | 1019 } else { |
991 surf_width, surface->h, | 1020 destscr = GEM_buffer2; |
992 SDL_FALSE, | 1021 destpitch = surface->pitch; |
993 surface->pitch, destpitch | 1022 } |
994 ); | 1023 |
995 } | 1024 SDL_Atari_C2pConvert(surface->pixels, destscr, |
996 | 1025 surf_width, surface->h, |
997 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { | 1026 SDL_FALSE, surface->pitch, destpitch); |
998 MFDB mfdb_src; | 1027 } |
999 short blitcoords[8]; | 1028 |
1000 | 1029 if (GEM_bufops & (B2S_VROCPYFM_1TOS | B2S_VROCPYFM_2TOS)) { |
1001 mfdb_src.fd_w=surf_width; | 1030 MFDB mfdb_src; |
1002 mfdb_src.fd_h=surface->h; | 1031 short blitcoords[8]; |
1003 mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4; | 1032 |
1004 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 1033 mfdb_src.fd_w = surf_width; |
1005 mfdb_src.fd_stand= | 1034 mfdb_src.fd_h = surface->h; |
1006 mfdb_src.fd_r1= | 1035 mfdb_src.fd_wdwidth = mfdb_src.fd_w >> 4; |
1007 mfdb_src.fd_r2= | 1036 mfdb_src.fd_nplanes = surface->format->BitsPerPixel; |
1008 mfdb_src.fd_r3= 0; | 1037 mfdb_src.fd_stand = |
1009 if (GEM_bufops & B2S_VROCPYFM_1TOS) { | 1038 mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0; |
1010 mfdb_src.fd_addr=surface->pixels; | 1039 if (GEM_bufops & B2S_VROCPYFM_1TOS) { |
1011 } else { | 1040 mfdb_src.fd_addr = surface->pixels; |
1012 mfdb_src.fd_addr=GEM_buffer2; | 1041 } else { |
1013 } | 1042 mfdb_src.fd_addr = GEM_buffer2; |
1014 | 1043 } |
1015 blitcoords[0] = blitcoords[4] = 0; | 1044 |
1016 blitcoords[1] = blitcoords[5] = 0; | 1045 blitcoords[0] = blitcoords[4] = 0; |
1017 blitcoords[2] = blitcoords[6] = surface->w - 1; | 1046 blitcoords[1] = blitcoords[5] = 0; |
1018 blitcoords[3] = blitcoords[7] = surface->h - 1; | 1047 blitcoords[2] = blitcoords[6] = surface->w - 1; |
1019 | 1048 blitcoords[3] = blitcoords[7] = surface->h - 1; |
1020 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | 1049 |
1021 } | 1050 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); |
1022 | 1051 } |
1023 return(0); | 1052 |
1024 } | 1053 return (0); |
1025 | 1054 } |
1026 static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface) | 1055 |
1027 { | 1056 static int |
1028 short pxy[8]; | 1057 GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface * surface) |
1029 | 1058 { |
1030 /* Update the whole window */ | 1059 short pxy[8]; |
1031 wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]); | 1060 |
1032 | 1061 /* Update the whole window */ |
1033 GEM_wind_redraw(this, GEM_handle, pxy); | 1062 wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]); |
1034 | 1063 |
1035 return(0); | 1064 GEM_wind_redraw(this, GEM_handle, pxy); |
1036 } | 1065 |
1037 | 1066 return (0); |
1038 static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface) | 1067 } |
1039 { | 1068 |
1040 if (GEM_lock_redraw) { | 1069 static int |
1041 return(0); | 1070 GEM_FlipHWSurface(_THIS, SDL_Surface * surface) |
1042 } | 1071 { |
1043 | 1072 if (GEM_lock_redraw) { |
1044 if (surface->flags & SDL_FULLSCREEN) { | 1073 return (0); |
1045 return GEM_FlipHWSurfaceFullscreen(this, surface); | 1074 } |
1046 } else { | 1075 |
1047 return GEM_FlipHWSurfaceWindowed(this, surface); | 1076 if (surface->flags & SDL_FULLSCREEN) { |
1048 } | 1077 return GEM_FlipHWSurfaceFullscreen(this, surface); |
1049 } | 1078 } else { |
1050 | 1079 return GEM_FlipHWSurfaceWindowed(this, surface); |
1051 static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 1080 } |
1052 { | 1081 } |
1053 int i; | 1082 |
1054 SDL_Surface *surface; | 1083 static int |
1084 GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) | |
1085 { | |
1086 int i; | |
1087 SDL_Surface *surface; | |
1055 | 1088 |
1056 #ifdef DEBUG_VIDEO_GEM | 1089 #ifdef DEBUG_VIDEO_GEM |
1057 printf("sdl:video:gem: setcolors()\n"); | 1090 printf("sdl:video:gem: setcolors()\n"); |
1058 #endif | 1091 #endif |
1059 | 1092 |
1060 /* Do not change palette in True Colour */ | 1093 /* Do not change palette in True Colour */ |
1061 surface = this->screen; | 1094 surface = this->screen; |
1062 if (surface->format->BitsPerPixel > 8) { | 1095 if (surface->format->BitsPerPixel > 8) { |
1063 return 1; | 1096 return 1; |
1064 } | 1097 } |
1065 | 1098 |
1066 for(i = 0; i < ncolors; i++) | 1099 for (i = 0; i < ncolors; i++) { |
1067 { | 1100 int r, g, b; |
1068 int r, g, b; | 1101 short rgb[3]; |
1069 short rgb[3]; | 1102 |
1070 | 1103 r = colors[i].r; |
1071 r = colors[i].r; | 1104 g = colors[i].g; |
1072 g = colors[i].g; | 1105 b = colors[i].b; |
1073 b = colors[i].b; | 1106 |
1074 | 1107 rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255; |
1075 rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255; | 1108 rgb[1] = VDI_curpalette[i][1] = (1000 * g) / 255; |
1076 rgb[1] = VDI_curpalette[i][1] =(1000 * g) / 255; | 1109 rgb[2] = VDI_curpalette[i][2] = (1000 * b) / 255; |
1077 rgb[2] = VDI_curpalette[i][2] =(1000 * b) / 255; | 1110 |
1078 | 1111 vs_color(VDI_handle, vdi_index[firstcolor + i], rgb); |
1079 vs_color(VDI_handle, vdi_index[firstcolor+i], rgb); | 1112 } |
1080 } | 1113 |
1081 | 1114 return (1); |
1082 return(1); | |
1083 } | 1115 } |
1084 | 1116 |
1085 #if 0 | 1117 #if 0 |
1086 static int GEM_ToggleFullScreen(_THIS, int on) | 1118 static int |
1087 { | 1119 GEM_ToggleFullScreen(_THIS, int on) |
1088 if (on) { | 1120 { |
1089 GEM_LockScreen(this); | 1121 if (on) { |
1090 } else { | 1122 GEM_LockScreen(this); |
1091 GEM_UnlockScreen(this); | 1123 } else { |
1092 } | 1124 GEM_UnlockScreen(this); |
1093 | 1125 } |
1094 return(1); | 1126 |
1127 return (1); | |
1095 } | 1128 } |
1096 #endif | 1129 #endif |
1097 | 1130 |
1098 /* Note: If we are terminated, this could be called in the middle of | 1131 /* Note: If we are terminated, this could be called in the middle of |
1099 another SDL video routine -- notably UpdateRects. | 1132 another SDL video routine -- notably UpdateRects. |
1100 */ | 1133 */ |
1101 void GEM_VideoQuit(_THIS) | 1134 void |
1102 { | 1135 GEM_VideoQuit(_THIS) |
1103 SDL_AtariXbios_RestoreVectors(); | 1136 { |
1104 if (GEM_usedevmouse) { | 1137 SDL_AtariXbios_RestoreVectors(); |
1105 SDL_AtariDevMouse_Close(); | 1138 if (GEM_usedevmouse) { |
1106 } | 1139 SDL_AtariDevMouse_Close(); |
1107 | 1140 } |
1108 GEM_FreeBuffers(this); | 1141 |
1142 GEM_FreeBuffers(this); | |
1109 | 1143 |
1110 #if SDL_VIDEO_OPENGL | 1144 #if SDL_VIDEO_OPENGL |
1111 if (gl_active) { | 1145 if (gl_active) { |
1112 SDL_AtariGL_Quit(this, SDL_TRUE); | 1146 SDL_AtariGL_Quit(this, SDL_TRUE); |
1113 } | 1147 } |
1114 #endif | 1148 #endif |
1115 | 1149 |
1116 /* Destroy window */ | 1150 /* Destroy window */ |
1117 if (GEM_handle>=0) { | 1151 if (GEM_handle >= 0) { |
1118 wind_close(GEM_handle); | 1152 wind_close(GEM_handle); |
1119 wind_delete(GEM_handle); | 1153 wind_delete(GEM_handle); |
1120 GEM_handle=-1; | 1154 GEM_handle = -1; |
1121 } | 1155 } |
1122 | 1156 |
1123 GEM_UnlockScreen(this); | 1157 GEM_UnlockScreen(this); |
1124 if (GEM_menubar) { | 1158 if (GEM_menubar) { |
1125 Mfree(GEM_menubar); | 1159 Mfree(GEM_menubar); |
1126 GEM_menubar=NULL; | 1160 GEM_menubar = NULL; |
1127 } | 1161 } |
1128 | 1162 |
1129 appl_exit(); | 1163 appl_exit(); |
1130 | 1164 |
1131 GEM_SetNewPalette(this, VDI_oldpalette); | 1165 GEM_SetNewPalette(this, VDI_oldpalette); |
1132 | 1166 |
1133 /* Close VDI workstation */ | 1167 /* Close VDI workstation */ |
1134 if (VDI_handle) { | 1168 if (VDI_handle) { |
1135 v_clsvwk(VDI_handle); | 1169 v_clsvwk(VDI_handle); |
1136 } | 1170 } |
1137 | 1171 |
1138 /* Free mode list */ | 1172 /* Free mode list */ |
1139 if (SDL_modelist[0]) { | 1173 if (SDL_modelist[0]) { |
1140 SDL_free(SDL_modelist[0]); | 1174 SDL_free(SDL_modelist[0]); |
1141 SDL_modelist[0]=NULL; | 1175 SDL_modelist[0] = NULL; |
1142 } | 1176 } |
1143 | 1177 |
1144 this->screen->pixels = NULL; | 1178 this->screen->pixels = NULL; |
1145 } | 1179 } |
1146 | 1180 |
1147 void GEM_wind_redraw(_THIS, int winhandle, short *inside) | 1181 void |
1148 { | 1182 GEM_wind_redraw(_THIS, int winhandle, short *inside) |
1149 short todo[4]; | 1183 { |
1150 | 1184 short todo[4]; |
1151 /* Tell AES we are going to update */ | 1185 |
1152 wind_update(BEG_UPDATE); | 1186 /* Tell AES we are going to update */ |
1153 | 1187 wind_update(BEG_UPDATE); |
1154 v_hide_c(VDI_handle); | 1188 |
1155 | 1189 v_hide_c(VDI_handle); |
1156 /* Browse the rectangle list to redraw */ | 1190 |
1157 if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) { | 1191 /* Browse the rectangle list to redraw */ |
1158 | 1192 if (wind_get |
1159 while (todo[2] && todo[3]) { | 1193 (winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], |
1160 | 1194 &todo[3]) != 0) { |
1161 if (rc_intersect((GRECT *)inside,(GRECT *)todo)) { | 1195 |
1162 todo[2] += todo[0]-1; | 1196 while (todo[2] && todo[3]) { |
1163 todo[3] += todo[1]-1; | 1197 |
1164 refresh_window(this, winhandle, todo); | 1198 if (rc_intersect((GRECT *) inside, (GRECT *) todo)) { |
1165 } | 1199 todo[2] += todo[0] - 1; |
1166 | 1200 todo[3] += todo[1] - 1; |
1167 if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) { | 1201 refresh_window(this, winhandle, todo); |
1168 break; | 1202 } |
1169 } | 1203 |
1170 } | 1204 if (wind_get |
1171 | 1205 (winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], |
1172 } | 1206 &todo[3]) == 0) { |
1173 | 1207 break; |
1174 /* Update finished */ | 1208 } |
1175 wind_update(END_UPDATE); | 1209 } |
1176 | 1210 |
1177 v_show_c(VDI_handle,1); | 1211 } |
1178 } | 1212 |
1179 | 1213 /* Update finished */ |
1180 static void refresh_window(_THIS, int winhandle, short *rect) | 1214 wind_update(END_UPDATE); |
1181 { | 1215 |
1182 MFDB mfdb_src; | 1216 v_show_c(VDI_handle, 1); |
1183 short pxy[8],wind_pxy[8]; | 1217 } |
1184 SDL_Surface *surface; | 1218 |
1185 int iconified; | 1219 static void |
1186 | 1220 refresh_window(_THIS, int winhandle, short *rect) |
1187 /* Is window iconified ? */ | 1221 { |
1188 iconified = 0; | 1222 MFDB mfdb_src; |
1189 /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ { | 1223 short pxy[8], wind_pxy[8]; |
1190 if (wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])!=0) { | 1224 SDL_Surface *surface; |
1191 iconified = wind_pxy[0]; | 1225 int iconified; |
1192 } | 1226 |
1193 } | 1227 /* Is window iconified ? */ |
1194 | 1228 iconified = 0; |
1195 if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { | 1229 /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ |
1196 return; | 1230 { |
1197 } | 1231 if (wind_get |
1198 | 1232 (winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], |
1199 if (iconified && GEM_icon) { | 1233 &wind_pxy[3]) != 0) { |
1200 short icon_rect[4], dst_rect[4]; | 1234 iconified = wind_pxy[0]; |
1201 short iconx,icony; | 1235 } |
1202 | 1236 } |
1203 surface = GEM_icon; | 1237 |
1204 | 1238 if (wind_get |
1205 GEM_ClearRect(this, rect); | 1239 (winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], |
1206 | 1240 &wind_pxy[3]) == 0) { |
1207 /* Calculate centered icon(x,y,w,h) relative to window */ | 1241 return; |
1208 iconx = (wind_pxy[2]-surface->w)>>1; | 1242 } |
1209 icony = (wind_pxy[3]-surface->h)>>1; | 1243 |
1210 | 1244 if (iconified && GEM_icon) { |
1211 icon_rect[0] = iconx; | 1245 short icon_rect[4], dst_rect[4]; |
1212 icon_rect[1] = icony; | 1246 short iconx, icony; |
1213 icon_rect[2] = surface->w; | 1247 |
1214 icon_rect[3] = surface->h; | 1248 surface = GEM_icon; |
1215 | 1249 |
1216 /* Calculate redraw rectangle(x,y,w,h) relative to window */ | 1250 GEM_ClearRect(this, rect); |
1217 dst_rect[0] = rect[0]-wind_pxy[0]; | 1251 |
1218 dst_rect[1] = rect[1]-wind_pxy[1]; | 1252 /* Calculate centered icon(x,y,w,h) relative to window */ |
1219 dst_rect[2] = rect[2]-rect[0]+1; | 1253 iconx = (wind_pxy[2] - surface->w) >> 1; |
1220 dst_rect[3] = rect[3]-rect[1]+1; | 1254 icony = (wind_pxy[3] - surface->h) >> 1; |
1221 | 1255 |
1222 /* Does the icon rectangle must be redrawn ? */ | 1256 icon_rect[0] = iconx; |
1223 if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) { | 1257 icon_rect[1] = icony; |
1224 return; | 1258 icon_rect[2] = surface->w; |
1225 } | 1259 icon_rect[3] = surface->h; |
1226 | 1260 |
1261 /* Calculate redraw rectangle(x,y,w,h) relative to window */ | |
1262 dst_rect[0] = rect[0] - wind_pxy[0]; | |
1263 dst_rect[1] = rect[1] - wind_pxy[1]; | |
1264 dst_rect[2] = rect[2] - rect[0] + 1; | |
1265 dst_rect[3] = rect[3] - rect[1] + 1; | |
1266 | |
1267 /* Does the icon rectangle must be redrawn ? */ | |
1268 if (!rc_intersect((GRECT *) icon_rect, (GRECT *) dst_rect)) { | |
1269 return; | |
1270 } | |
1227 #if DEBUG_VIDEO_GEM | 1271 #if DEBUG_VIDEO_GEM |
1228 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", | 1272 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", |
1229 surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]); | 1273 surface->w - 1, surface->h - 1, dst_rect[0], dst_rect[1], |
1230 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", | 1274 dst_rect[2], dst_rect[3]); |
1231 icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]); | 1275 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", icon_rect[0], |
1232 printf("sdl:video:gem: refresh_window(): draw icon\n"); | 1276 icon_rect[1], icon_rect[2], icon_rect[3]); |
1233 #endif | 1277 printf("sdl:video:gem: refresh_window(): draw icon\n"); |
1234 | 1278 #endif |
1235 /* Calculate icon(x1,y1,x2,y2) relative to screen */ | 1279 |
1236 icon_rect[0] += wind_pxy[0]; | 1280 /* Calculate icon(x1,y1,x2,y2) relative to screen */ |
1237 icon_rect[1] += wind_pxy[1]; | 1281 icon_rect[0] += wind_pxy[0]; |
1238 icon_rect[2] += icon_rect[0]-1; | 1282 icon_rect[1] += wind_pxy[1]; |
1239 icon_rect[3] += icon_rect[1]-1; | 1283 icon_rect[2] += icon_rect[0] - 1; |
1240 | 1284 icon_rect[3] += icon_rect[1] - 1; |
1241 /* Calculate intersection rectangle to redraw */ | 1285 |
1242 pxy[4]=pxy[0]=MAX(icon_rect[0],rect[0]); | 1286 /* Calculate intersection rectangle to redraw */ |
1243 pxy[5]=pxy[1]=MAX(icon_rect[1],rect[1]); | 1287 pxy[4] = pxy[0] = MAX(icon_rect[0], rect[0]); |
1244 pxy[6]=pxy[2]=MIN(icon_rect[2],rect[2]); | 1288 pxy[5] = pxy[1] = MAX(icon_rect[1], rect[1]); |
1245 pxy[7]=pxy[3]=MIN(icon_rect[3],rect[3]); | 1289 pxy[6] = pxy[2] = MIN(icon_rect[2], rect[2]); |
1246 | 1290 pxy[7] = pxy[3] = MIN(icon_rect[3], rect[3]); |
1247 /* Calculate icon source image pos relative to window */ | 1291 |
1248 pxy[0] -= wind_pxy[0]+iconx; | 1292 /* Calculate icon source image pos relative to window */ |
1249 pxy[1] -= wind_pxy[1]+icony; | 1293 pxy[0] -= wind_pxy[0] + iconx; |
1250 pxy[2] -= wind_pxy[0]+iconx; | 1294 pxy[1] -= wind_pxy[1] + icony; |
1251 pxy[3] -= wind_pxy[1]+icony; | 1295 pxy[2] -= wind_pxy[0] + iconx; |
1252 | 1296 pxy[3] -= wind_pxy[1] + icony; |
1253 } else { | 1297 |
1254 surface = this->screen; | 1298 } else { |
1299 surface = this->screen; | |
1255 | 1300 |
1256 #if DEBUG_VIDEO_GEM | 1301 #if DEBUG_VIDEO_GEM |
1257 printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); | 1302 printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); |
1258 #endif | 1303 #endif |
1259 | 1304 |
1260 /* Redraw all window content */ | 1305 /* Redraw all window content */ |
1261 pxy[0] = rect[0]-wind_pxy[0]; | 1306 pxy[0] = rect[0] - wind_pxy[0]; |
1262 pxy[1] = rect[1]-wind_pxy[1]; | 1307 pxy[1] = rect[1] - wind_pxy[1]; |
1263 pxy[2] = rect[2]-wind_pxy[0]; | 1308 pxy[2] = rect[2] - wind_pxy[0]; |
1264 pxy[3] = rect[3]-wind_pxy[1]; | 1309 pxy[3] = rect[3] - wind_pxy[1]; |
1265 | 1310 |
1266 pxy[4] = rect[0]; | 1311 pxy[4] = rect[0]; |
1267 pxy[5] = rect[1]; | 1312 pxy[5] = rect[1]; |
1268 pxy[6] = rect[2]; | 1313 pxy[6] = rect[2]; |
1269 pxy[7] = rect[3]; | 1314 pxy[7] = rect[3]; |
1270 } | 1315 } |
1271 | 1316 |
1272 if (GEM_bufops & B2S_C2P_1TO2) { | 1317 if (GEM_bufops & B2S_C2P_1TO2) { |
1273 void *src, *dest; | 1318 void *src, *dest; |
1274 int x1,x2; | 1319 int x1, x2; |
1275 | 1320 |
1276 x1 = (rect[0]-wind_pxy[0]) & ~15; | 1321 x1 = (rect[0] - wind_pxy[0]) & ~15; |
1277 x2 = rect[2]-wind_pxy[0]; | 1322 x2 = rect[2] - wind_pxy[0]; |
1278 if (x2 & 15) { | 1323 if (x2 & 15) { |
1279 x2 = (x2 | 15) +1; | 1324 x2 = (x2 | 15) + 1; |
1280 } | 1325 } |
1281 | 1326 |
1282 src = surface->pixels; | 1327 src = surface->pixels; |
1283 src += surface->pitch * (rect[1]-wind_pxy[1]); | 1328 src += surface->pitch * (rect[1] - wind_pxy[1]); |
1284 src += x1; | 1329 src += x1; |
1285 | 1330 |
1286 dest = GEM_buffer2; | 1331 dest = GEM_buffer2; |
1287 dest += surface->pitch * (rect[1]-wind_pxy[1]); | 1332 dest += surface->pitch * (rect[1] - wind_pxy[1]); |
1288 dest += x1; | 1333 dest += x1; |
1289 | 1334 |
1290 SDL_Atari_C2pConvert( | 1335 SDL_Atari_C2pConvert(src, dest, |
1291 src, dest, | 1336 x2 - x1, rect[3] - rect[1] + 1, |
1292 x2-x1, rect[3]-rect[1]+1, | 1337 SDL_FALSE, surface->pitch, surface->pitch); |
1293 SDL_FALSE, | 1338 } |
1294 surface->pitch, surface->pitch | 1339 |
1295 ); | 1340 mfdb_src.fd_addr = surface->pixels; |
1296 } | 1341 { |
1297 | 1342 int width; |
1298 mfdb_src.fd_addr=surface->pixels; | 1343 |
1299 { | 1344 /* Need to be a multiple of 16 pixels */ |
1300 int width; | 1345 width = surface->w; |
1301 | 1346 if ((width & 15) != 0) { |
1302 /* Need to be a multiple of 16 pixels */ | 1347 width = (width | 15) + 1; |
1303 width=surface->w; | 1348 } |
1304 if ((width & 15) != 0) { | 1349 mfdb_src.fd_w = width; |
1305 width = (width | 15) + 1; | 1350 } |
1306 } | 1351 mfdb_src.fd_h = surface->h; |
1307 mfdb_src.fd_w=width; | 1352 mfdb_src.fd_nplanes = surface->format->BitsPerPixel; |
1308 } | 1353 mfdb_src.fd_wdwidth = mfdb_src.fd_w >> 4; |
1309 mfdb_src.fd_h=surface->h; | 1354 mfdb_src.fd_stand = mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0; |
1310 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 1355 |
1311 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; | 1356 if (GEM_bufops & B2S_VROCPYFM_2TOS) { |
1312 mfdb_src.fd_stand= | 1357 mfdb_src.fd_addr = GEM_buffer2; |
1313 mfdb_src.fd_r1= | 1358 } |
1314 mfdb_src.fd_r2= | |
1315 mfdb_src.fd_r3= 0; | |
1316 | |
1317 if (GEM_bufops & B2S_VROCPYFM_2TOS) { | |
1318 mfdb_src.fd_addr=GEM_buffer2; | |
1319 } | |
1320 | |
1321 #if DEBUG_VIDEO_GEM | 1359 #if DEBUG_VIDEO_GEM |
1322 printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", | 1360 printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", |
1323 surface->w, surface->h, | 1361 surface->w, surface->h, |
1324 pxy[0],pxy[1],pxy[2],pxy[3], | 1362 pxy[0], pxy[1], pxy[2], pxy[3], pxy[4], pxy[5], pxy[6], pxy[7]); |
1325 pxy[4],pxy[5],pxy[6],pxy[7] | 1363 #endif |
1326 ); | 1364 |
1327 #endif | 1365 vro_cpyfm(VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); |
1328 | |
1329 vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); | |
1330 } | 1366 } |
1331 | 1367 |
1332 #if SDL_VIDEO_OPENGL | 1368 #if SDL_VIDEO_OPENGL |
1333 | 1369 |
1334 static void GEM_GL_SwapBuffers(_THIS) | 1370 static void |
1335 { | 1371 GEM_GL_SwapBuffers(_THIS) |
1336 SDL_AtariGL_SwapBuffers(this); | 1372 { |
1337 GEM_FlipHWSurface(this, this->screen); | 1373 SDL_AtariGL_SwapBuffers(this); |
1338 } | 1374 GEM_FlipHWSurface(this, this->screen); |
1339 | 1375 } |
1340 #endif | 1376 |
1377 #endif | |
1378 /* vi: set ts=4 sw=4 expandtab: */ |