Mercurial > sdl-ios-xcode
comparison src/video/gem/SDL_gemvideo.c @ 736:028e03e273c8
Use new C2P routine + corrections for iconification window
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Wed, 12 Nov 2003 18:49:29 +0000 |
parents | 0136d21b7764 |
children | 7e4347dd2f9c |
comparison
equal
deleted
inserted
replaced
735:abec2a842d11 | 736:028e03e273c8 |
---|---|
24 static char rcsid = | 24 static char rcsid = |
25 "@(#) $Id$"; | 25 "@(#) $Id$"; |
26 #endif | 26 #endif |
27 | 27 |
28 /* | 28 /* |
29 * GEM SDL video driver implementation | 29 GEM video driver |
30 * inspired from the Dummy SDL driver | 30 |
31 * | 31 Patrice Mandin |
32 * Patrice Mandin | 32 and work from |
33 * and work from | 33 Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard |
34 * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard | 34 */ |
35 */ | |
36 | 35 |
37 #include <stdio.h> | 36 #include <stdio.h> |
38 #include <stdlib.h> | 37 #include <stdlib.h> |
39 #include <string.h> | 38 #include <string.h> |
40 | 39 |
52 #include "SDL_pixels_c.h" | 51 #include "SDL_pixels_c.h" |
53 #include "SDL_events_c.h" | 52 #include "SDL_events_c.h" |
54 #include "SDL_cursor_c.h" | 53 #include "SDL_cursor_c.h" |
55 | 54 |
56 #include "SDL_ataric2p_s.h" | 55 #include "SDL_ataric2p_s.h" |
57 #include "SDL_ataric2p060_c.h" | |
58 #include "SDL_atarieddi_s.h" | 56 #include "SDL_atarieddi_s.h" |
59 #include "SDL_atarimxalloc_c.h" | 57 #include "SDL_atarimxalloc_c.h" |
60 #include "SDL_gemvideo.h" | 58 #include "SDL_gemvideo.h" |
61 #include "SDL_gemevents_c.h" | 59 #include "SDL_gemevents_c.h" |
62 #include "SDL_gemmouse_c.h" | 60 #include "SDL_gemmouse_c.h" |
63 #include "SDL_gemwm_c.h" | 61 #include "SDL_gemwm_c.h" |
64 #include "SDL_xbiosevents_c.h" | 62 #include "SDL_xbiosevents_c.h" |
65 | 63 |
66 /* Defines */ | 64 /* Defines */ |
65 | |
66 /*#define DEBUG_VIDEO_GEM 1*/ | |
67 | 67 |
68 #define GEM_VID_DRIVER_NAME "gem" | 68 #define GEM_VID_DRIVER_NAME "gem" |
69 | 69 |
70 /* Variables */ | 70 /* Variables */ |
71 | 71 |
95 #endif | 95 #endif |
96 | 96 |
97 /* Internal functions */ | 97 /* Internal functions */ |
98 static void GEM_FreeBuffers(_THIS); | 98 static void GEM_FreeBuffers(_THIS); |
99 static void GEM_ClearScreen(_THIS); | 99 static void GEM_ClearScreen(_THIS); |
100 static void GEM_ClearRect(_THIS, short *rect); | |
100 static void GEM_LockScreen(_THIS); | 101 static void GEM_LockScreen(_THIS); |
101 static void GEM_UnlockScreen(_THIS); | 102 static void GEM_UnlockScreen(_THIS); |
102 static void refresh_window(_THIS, int winhandle, short *rect); | 103 static void refresh_window(_THIS, int winhandle, short *rect); |
103 | 104 |
104 /* GEM driver bootstrap functions */ | 105 /* GEM driver bootstrap functions */ |
136 free(device); | 137 free(device); |
137 } | 138 } |
138 return(0); | 139 return(0); |
139 } | 140 } |
140 memset(device->hidden, 0, (sizeof *device->hidden)); | 141 memset(device->hidden, 0, (sizeof *device->hidden)); |
141 | |
142 atari_test_cpu060_present(); | |
143 | 142 |
144 /* Set the function pointers */ | 143 /* Set the function pointers */ |
145 device->VideoInit = GEM_VideoInit; | 144 device->VideoInit = GEM_VideoInit; |
146 device->ListModes = GEM_ListModes; | 145 device->ListModes = GEM_ListModes; |
147 device->SetVideoMode = GEM_SetVideoMode; | 146 device->SetVideoMode = GEM_SetVideoMode; |
155 device->FreeHWSurface = GEM_FreeHWSurface; | 154 device->FreeHWSurface = GEM_FreeHWSurface; |
156 device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/; | 155 device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/; |
157 | 156 |
158 /* Window manager */ | 157 /* Window manager */ |
159 device->SetCaption = GEM_SetCaption; | 158 device->SetCaption = GEM_SetCaption; |
160 device->SetIcon = NULL /*GEM_SetIcon*/; | 159 device->SetIcon = GEM_SetIcon; |
161 device->IconifyWindow = GEM_IconifyWindow; | 160 device->IconifyWindow = GEM_IconifyWindow; |
162 device->GrabInput = GEM_GrabInput; | 161 device->GrabInput = GEM_GrabInput; |
163 | 162 |
164 /* Events */ | 163 /* Events */ |
165 device->InitOSKeymap = GEM_InitOSKeymap; | 164 device->InitOSKeymap = GEM_InitOSKeymap; |
216 switch(num_colours) { | 215 switch(num_colours) { |
217 case 32768UL: | 216 case 32768UL: |
218 if (work_out[14] & (1<<7)) { | 217 if (work_out[14] & (1<<7)) { |
219 /* Little endian */ | 218 /* Little endian */ |
220 if (work_out[14] & (1<<1)) { | 219 if (work_out[14] & (1<<1)) { |
221 /* Falcon */ | 220 VDI_FBMASK(1<<13, 31<<3, (3<<14)|7, 31<<8); |
222 VDI_alphamask = 1 << 13; | |
223 VDI_redmask = 31 << 3; | |
224 VDI_greenmask = (3 << 14) | 7; | |
225 VDI_bluemask = 31 << 8; | |
226 } else { | 221 } else { |
227 /* Others */ | 222 VDI_FBMASK(1<<7, 31<<2, (7<<13)|3, 31<<8); |
228 VDI_alphamask = 1 << 7; | |
229 VDI_redmask = 31 << 2; | |
230 VDI_greenmask = (7 << 13) | 3; | |
231 VDI_bluemask = 31 << 8; | |
232 } | 223 } |
233 } else { | 224 } else { |
234 /* Big endian */ | 225 /* Big endian */ |
235 if (work_out[14] & (1<<1)) { | 226 if (work_out[14] & (1<<1)) { |
236 /* Falcon */ | 227 VDI_FBMASK(1<<5, 31<<11, 31<<6, 31); |
237 VDI_alphamask = 1 << 5; | |
238 VDI_redmask = 31 << 11; | |
239 VDI_greenmask = 31 << 6; | |
240 VDI_bluemask = 31; | |
241 } else { | 228 } else { |
242 /* Others */ | 229 VDI_FBMASK(1<<15, 31<<10, 31<<5, 31); |
243 VDI_alphamask = 1 << 15; | |
244 VDI_redmask = 31 << 10; | |
245 VDI_greenmask = 31 << 5; | |
246 VDI_bluemask = 31; | |
247 } | 230 } |
248 } | 231 } |
249 break; | 232 break; |
250 case 65536UL: | 233 case 65536UL: |
251 if (work_out[14] & (1<<7)) { | 234 if (work_out[14] & (1<<7)) { |
252 /* Little endian */ | 235 /* Little endian */ |
253 VDI_alphamask = 0; | 236 VDI_FBMASK(0, 31<<3, (7<<13)|7, 31<<8); |
254 VDI_redmask = 31 << 3; | |
255 VDI_greenmask = (7 << 13) | 7; | |
256 VDI_bluemask = 31 << 8; | |
257 } else { | 237 } else { |
258 /* Big endian */ | 238 /* Big endian */ |
259 VDI_alphamask = 0; | 239 VDI_FBMASK(0, 31<<11, 63<<5, 31); |
260 VDI_redmask = 31 << 11; | |
261 VDI_greenmask = 63 << 5; | |
262 VDI_bluemask = 31; | |
263 } | 240 } |
264 break; | 241 break; |
265 case 16777216UL: | 242 case 16777216UL: |
266 if (work_out[14] & (1<<7)) { | 243 if (work_out[14] & (1<<7)) { |
267 /* Little endian */ | 244 /* Little endian */ |
268 switch(num_bits) { | 245 switch(num_bits) { |
269 case 24: | 246 case 24: |
270 VDI_alphamask = 0; | 247 VDI_FBMASK(0, 255, 255<<8, 255<<16); |
271 VDI_redmask = 255; | |
272 VDI_greenmask = 255 << 8; | |
273 VDI_bluemask = 255 << 16; | |
274 break; | 248 break; |
275 case 32: | 249 case 32: |
276 VDI_alphamask = 255; | 250 VDI_FBMASK(255, 255<<8, 255<<16, 255<<24); |
277 VDI_redmask = 255 << 8; | |
278 VDI_greenmask = 255 << 16; | |
279 VDI_bluemask = 255 << 24; | |
280 break; | 251 break; |
281 } | 252 } |
282 } else { | 253 } else { |
283 /* Big endian */ | 254 /* Big endian */ |
284 switch(num_bits) { | 255 switch(num_bits) { |
285 case 24: | 256 case 24: |
286 VDI_alphamask = 0; | 257 VDI_FBMASK(0, 255<<16, 255<<8, 255); |
287 VDI_redmask = 255 << 16; | |
288 VDI_greenmask = 255 << 8; | |
289 VDI_bluemask = 255; | |
290 break; | 258 break; |
291 case 32: | 259 case 32: |
292 VDI_alphamask = 255 << 24; | 260 VDI_FBMASK(255<<24, 255<<16, 255<<8, 255); |
293 VDI_redmask = 255 << 16; | |
294 VDI_greenmask = 255 << 8; | |
295 VDI_bluemask = 255; | |
296 break; | 261 break; |
297 } | 262 } |
298 } | 263 } |
299 break; | 264 break; |
300 } | 265 } |
369 fprintf(stderr,"Can not open AES\n"); | 334 fprintf(stderr,"Can not open AES\n"); |
370 return 1; | 335 return 1; |
371 } | 336 } |
372 | 337 |
373 /* Read version and features */ | 338 /* Read version and features */ |
374 GEM_version = aes_params.global[0]; | 339 GEM_version = aes_global[0]; |
375 if (GEM_version >= 0x0400) { | 340 if (GEM_version >= 0x0410) { |
376 short ap_gout[4]; | 341 short ap_gout[4], errorcode; |
377 | 342 |
343 #ifdef DEBUG_VIDEO_GEM | |
344 printf("sdl:video:gem: AES %02x.%02x\n", (GEM_version>>8) & 0xff, GEM_version & 0xff); | |
345 #endif | |
346 | |
378 GEM_wfeatures=0; | 347 GEM_wfeatures=0; |
379 if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3])==0) { | 348 errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]); |
349 #ifdef DEBUG_VIDEO_GEM | |
350 printf("sdl:video:gem: appl_getinfo() returned 0x%04x\n", errorcode); | |
351 #endif | |
352 | |
353 if (errorcode==0) { | |
380 GEM_wfeatures=ap_gout[0]; | 354 GEM_wfeatures=ap_gout[0]; |
355 | |
356 #ifdef DEBUG_VIDEO_GEM | |
357 printf("sdl:video:gem: AES wind_*() modes: 0x%04x\n", GEM_wfeatures); | |
358 printf("sdl:video:gem: AES window behaviours: 0x%04x\n", ap_gout[3]); | |
359 } else { | |
360 printf("sdl:video:gem: apgout[]={0x%04x,0x%04x,0x%04x,0x%04x}\n", | |
361 ap_gout[0], ap_gout[1], ap_gout[1], ap_gout[3] | |
362 ); | |
363 #endif | |
381 } | 364 } |
382 } | 365 } |
383 | 366 |
384 /* Ask VDI physical workstation handle opened by AES */ | 367 /* Ask VDI physical workstation handle opened by AES */ |
385 VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); | 368 VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); |
467 | 450 |
468 VDI_screen = NULL; | 451 VDI_screen = NULL; |
469 VDI_ReadExtInfo(this, work_out); | 452 VDI_ReadExtInfo(this, work_out); |
470 if (VDI_screen == NULL) { | 453 if (VDI_screen == NULL) { |
471 VDI_pitch = VDI_w * VDI_pixelsize; | 454 VDI_pitch = VDI_w * VDI_pixelsize; |
472 VDI_format = VDI_FORMAT_UNKNOWN; | 455 VDI_format = VDI_FORMAT_PACK; |
456 if (VDI_bpp <= 8) { | |
457 VDI_format = VDI_FORMAT_INTER; | |
458 } | |
473 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; | 459 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; |
474 } | 460 } |
475 | 461 |
476 /* Setup destination mfdb */ | 462 /* Setup destination mfdb */ |
477 VDI_dst_mfdb.fd_addr = NULL; | 463 VDI_dst_mfdb.fd_addr = NULL; |
478 | 464 |
479 /* Update hardware info */ | 465 /* Update hardware info */ |
480 this->info.hw_available = 0; | 466 this->info.hw_available = 0; |
481 this->info.video_mem = 0; | 467 this->info.video_mem = 0; |
482 | 468 |
483 /* TC, screen : no shadow (direct) | |
484 * 8P, screen: no shadow (direct) | |
485 * 8I, screen: shadow, c2p (shadow -> c2p) | |
486 * TC, no screen: shadow (vro_cpyfm) | |
487 * 8P, no screen: shadow (vro_cpyfm) | |
488 * 8I/U, no screen: shadow, shadow_c2p, c2p (shadow -> c2p -> vro_cpyfm) | |
489 */ | |
490 | |
491 /* Determine the screen depth */ | 469 /* Determine the screen depth */ |
492 /* we change this during the SDL_SetVideoMode implementation... */ | 470 /* we change this during the SDL_SetVideoMode implementation... */ |
493 vformat->BitsPerPixel = VDI_bpp; | 471 vformat->BitsPerPixel = VDI_bpp; |
494 | 472 |
495 /* Set mouse cursor to arrow */ | 473 /* Set mouse cursor to arrow */ |
496 graf_mouse(ARROW, NULL); | 474 graf_mouse(ARROW, NULL); |
497 | 475 |
498 /* Init chunky to planar routine */ | 476 /* Init chunky to planar routine */ |
499 Atari_C2pInit = Atari_C2pInit8; | 477 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; |
500 if (atari_cpu060_avail) { | 478 |
501 Atari_C2pConvert = Atari_C2pConvert8_060; | 479 /* Setup VDI fill functions */ |
502 } else { | 480 vsf_color(VDI_handle,0); |
503 Atari_C2pConvert = Atari_C2pConvert8; | 481 vsf_interior(VDI_handle,1); |
504 } | 482 vsf_perimeter(VDI_handle,0); |
505 Atari_C2pInit(); | 483 |
484 #ifdef DEBUG_VIDEO_GEM | |
485 printf("sdl:video:gem: VideoInit(): done\n"); | |
486 #endif | |
506 | 487 |
507 /* We're done! */ | 488 /* We're done! */ |
508 return(0); | 489 return(0); |
509 } | 490 } |
510 | 491 |
518 } | 499 } |
519 | 500 |
520 static void GEM_FreeBuffers(_THIS) | 501 static void GEM_FreeBuffers(_THIS) |
521 { | 502 { |
522 /* Release buffer */ | 503 /* Release buffer */ |
523 if ( GEM_buffer ) { | 504 if ( GEM_buffer2 ) { |
524 free( GEM_buffer ); | 505 free( GEM_buffer2 ); |
525 GEM_buffer=NULL; | 506 GEM_buffer2=NULL; |
507 } | |
508 | |
509 if ( GEM_buffer1 ) { | |
510 free( GEM_buffer1 ); | |
511 GEM_buffer1=NULL; | |
526 } | 512 } |
527 | 513 |
528 /* Destroy window */ | 514 /* Destroy window */ |
529 if (GEM_handle>=0) { | 515 if (GEM_handle>=0) { |
530 wind_close(GEM_handle); | 516 wind_close(GEM_handle); |
531 wind_delete(GEM_handle); | 517 wind_delete(GEM_handle); |
532 GEM_handle=-1; | 518 GEM_handle=-1; |
533 } | 519 } |
534 } | 520 } |
535 | 521 |
536 static void GEM_ClearScreen(_THIS) | 522 static void GEM_ClearRect(_THIS, short *rect) |
537 { | 523 { |
538 short rgb[3]={0,0,0}; | 524 short oldrgb[3], rgb[3]={0,0,0}; |
539 short oldrgb[3]; | |
540 short pxy[4]; | |
541 | |
542 v_hide_c(VDI_handle); | |
543 | 525 |
544 vq_color(VDI_handle, vdi_index[0], 0, oldrgb); | 526 vq_color(VDI_handle, vdi_index[0], 0, oldrgb); |
545 vs_color(VDI_handle, vdi_index[0], rgb); | 527 vs_color(VDI_handle, vdi_index[0], rgb); |
528 | |
529 vsf_color(VDI_handle,0); | |
530 vsf_interior(VDI_handle,1); | |
531 vsf_perimeter(VDI_handle,0); | |
532 v_bar(VDI_handle, rect); | |
533 | |
534 vs_color(VDI_handle, vdi_index[0], oldrgb); | |
535 } | |
536 | |
537 static void GEM_ClearScreen(_THIS) | |
538 { | |
539 short pxy[4]; | |
540 | |
541 v_hide_c(VDI_handle); | |
546 | 542 |
547 pxy[0] = pxy[1] = 0; | 543 pxy[0] = pxy[1] = 0; |
548 pxy[2] = VDI_w - 1; | 544 pxy[2] = VDI_w - 1; |
549 pxy[3] = VDI_h - 1; | 545 pxy[3] = VDI_h - 1; |
550 vsf_color(VDI_handle,0); | 546 GEM_ClearRect(this, pxy); |
551 vsf_interior(VDI_handle,1); | |
552 vsf_perimeter(VDI_handle,0); | |
553 v_bar(VDI_handle,pxy); | |
554 | |
555 vs_color(VDI_handle, vdi_index[0], oldrgb); | |
556 | 547 |
557 v_show_c(VDI_handle, 1); | 548 v_show_c(VDI_handle, 1); |
558 } | 549 } |
559 | 550 |
560 static void GEM_LockScreen(_THIS) | 551 static void GEM_LockScreen(_THIS) |
586 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, | 577 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, |
587 int width, int height, int bpp, Uint32 flags) | 578 int width, int height, int bpp, Uint32 flags) |
588 { | 579 { |
589 int maxwidth, maxheight; | 580 int maxwidth, maxheight; |
590 Uint32 modeflags, screensize; | 581 Uint32 modeflags, screensize; |
591 SDL_bool use_shadow; | 582 SDL_bool use_shadow1, use_shadow2; |
592 | 583 |
593 GEM_FreeBuffers(this); | 584 GEM_FreeBuffers(this); |
594 | 585 |
595 /*--- Verify if asked mode can be used ---*/ | 586 /*--- Verify if asked mode can be used ---*/ |
596 if (flags & SDL_FULLSCREEN) { | 587 if (flags & SDL_FULLSCREEN) { |
611 if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) { | 602 if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) { |
612 SDL_SetError("Couldn't allocate new pixel format for requested mode"); | 603 SDL_SetError("Couldn't allocate new pixel format for requested mode"); |
613 return(NULL); | 604 return(NULL); |
614 } | 605 } |
615 | 606 |
616 /*--- Allocate shadow buffer if needed ---*/ | 607 screensize = width * height * VDI_pixelsize; |
617 use_shadow=SDL_FALSE; | 608 |
618 if (flags & SDL_FULLSCREEN) { | 609 /*--- Allocate shadow buffers if needed, and conversion operations ---*/ |
619 if (!VDI_screen) { | 610 GEM_bufops=0; |
620 /* No access to real framebuffer, use shadow surface */ | 611 use_shadow1=use_shadow2=SDL_FALSE; |
621 use_shadow=SDL_TRUE; | 612 if (VDI_screen && (flags & SDL_FULLSCREEN)) { |
613 if (VDI_format==VDI_FORMAT_INTER) { | |
614 use_shadow1=SDL_TRUE; | |
615 GEM_bufops = B2S_C2P_1TOS; | |
616 } | |
617 } else { | |
618 use_shadow1=SDL_TRUE; | |
619 if (VDI_format==VDI_FORMAT_PACK) { | |
620 GEM_bufops = B2S_VROCPYFM_1TOS; | |
622 } else { | 621 } else { |
623 if (VDI_format==VDI_FORMAT_INTER) { | 622 use_shadow2=SDL_TRUE; |
624 /* Real framebuffer, interleaved bitplanes, | 623 GEM_bufops = B2S_C2P_1TO2|B2S_VROCPYFM_2TOS; |
625 use shadow surface */ | 624 } |
626 use_shadow=SDL_TRUE; | 625 } |
627 } else if (flags & SDL_DOUBLEBUF) { | 626 |
628 /* Real framebuffer, double-buffered, | 627 if (use_shadow1) { |
629 use shadow surface */ | 628 GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM); |
630 use_shadow=SDL_TRUE; | 629 if (GEM_buffer1==NULL) { |
631 modeflags |= SDL_DOUBLEBUF; | |
632 } | |
633 } | |
634 } else { | |
635 /* Windowed mode, always with shadow surface */ | |
636 use_shadow=SDL_TRUE; | |
637 } | |
638 | |
639 if (use_shadow) { | |
640 screensize = width * height * VDI_pixelsize; | |
641 | |
642 GEM_buffer = Atari_SysMalloc(screensize, MX_PREFTTRAM); | |
643 if (GEM_buffer==NULL) { | |
644 fprintf(stderr,"Unable to allocate shadow buffer\n"); | 630 fprintf(stderr,"Unable to allocate shadow buffer\n"); |
645 return NULL; | 631 return NULL; |
646 } | 632 } |
647 memset(GEM_buffer, 0, screensize); | 633 memset(GEM_buffer1, 0, screensize); |
634 #ifdef DEBUG_VIDEO_GEM | |
635 printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); | |
636 #endif | |
637 } | |
638 | |
639 if (use_shadow2) { | |
640 GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM); | |
641 if (GEM_buffer2==NULL) { | |
642 fprintf(stderr,"Unable to allocate shadow buffer\n"); | |
643 return NULL; | |
644 } | |
645 memset(GEM_buffer2, 0, screensize); | |
646 #ifdef DEBUG_VIDEO_GEM | |
647 printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); | |
648 #endif | |
648 } | 649 } |
649 | 650 |
650 /*--- Initialize screen ---*/ | 651 /*--- Initialize screen ---*/ |
651 modeflags = 0; | 652 modeflags = 0; |
652 if (VDI_bpp == 8) { | 653 if (VDI_bpp == 8) { |
657 GEM_LockScreen(this); | 658 GEM_LockScreen(this); |
658 | 659 |
659 GEM_ClearScreen(this); | 660 GEM_ClearScreen(this); |
660 | 661 |
661 modeflags |= SDL_FULLSCREEN; | 662 modeflags |= SDL_FULLSCREEN; |
662 if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow) { | 663 if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow1) { |
663 modeflags |= SDL_HWSURFACE; | 664 modeflags |= SDL_HWSURFACE; |
664 } else { | 665 } else { |
665 modeflags |= SDL_SWSURFACE; | 666 modeflags |= SDL_SWSURFACE; |
666 } | 667 } |
667 } else { | 668 } else { |
702 GEM_FreeBuffers(this); | 703 GEM_FreeBuffers(this); |
703 fprintf(stderr,"Can not create window\n"); | 704 fprintf(stderr,"Can not create window\n"); |
704 return NULL; | 705 return NULL; |
705 } | 706 } |
706 | 707 |
708 #ifdef DEBUG_VIDEO_GEM | |
709 printf("sdl:video:gem: handle=%d\n", GEM_handle); | |
710 #endif | |
711 | |
707 /* Setup window name */ | 712 /* Setup window name */ |
708 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); | 713 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); |
714 GEM_refresh_name = SDL_FALSE; | |
709 | 715 |
710 /* Open the window */ | 716 /* Open the window */ |
711 wind_open(GEM_handle,x2,y2,w2,h2); | 717 wind_open(GEM_handle,x2,y2,w2,h2); |
712 | 718 |
713 modeflags |= SDL_SWSURFACE; | 719 modeflags |= SDL_SWSURFACE; |
715 | 721 |
716 /* Set up the new mode framebuffer */ | 722 /* Set up the new mode framebuffer */ |
717 current->flags = modeflags; | 723 current->flags = modeflags; |
718 current->w = width; | 724 current->w = width; |
719 current->h = height; | 725 current->h = height; |
720 if (use_shadow) { | 726 if (use_shadow1) { |
721 current->pixels = GEM_buffer; | 727 current->pixels = GEM_buffer1; |
722 current->pitch = width * (VDI_bpp >> 3); | 728 current->pitch = width * (VDI_bpp >> 3); |
723 } else { | 729 } else { |
724 current->pixels = VDI_screen; | 730 current->pixels = VDI_screen; |
725 current->pixels += VDI_pitch * ((VDI_h - height) >> 1); | 731 current->pixels += VDI_pitch * ((VDI_h - height) >> 1); |
726 current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1); | 732 current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1); |
731 | 737 |
732 /* We're done */ | 738 /* We're done */ |
733 return(current); | 739 return(current); |
734 } | 740 } |
735 | 741 |
736 /* We don't actually allow hardware surfaces other than the main one */ | |
737 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) | 742 static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) |
738 { | 743 { |
739 return -1; | 744 return -1; |
740 } | 745 } |
741 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface) | 746 static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface) |
742 { | 747 { |
743 return; | 748 return; |
744 } | 749 } |
745 | 750 |
746 /* We need to wait for vertical retrace on page flipped displays */ | |
747 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface) | 751 static int GEM_LockHWSurface(_THIS, SDL_Surface *surface) |
748 { | 752 { |
749 return(0); | 753 return(0); |
750 } | 754 } |
751 | 755 |
755 } | 759 } |
756 | 760 |
757 static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) | 761 static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) |
758 { | 762 { |
759 SDL_Surface *surface; | 763 SDL_Surface *surface; |
760 MFDB mfdb_src; | |
761 short blitcoords[8]; | |
762 int i; | 764 int i; |
763 | 765 |
764 surface = this->screen; | 766 surface = this->screen; |
765 | 767 |
766 if (VDI_screen) { | 768 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { |
767 if (VDI_format==VDI_FORMAT_INTER) { | 769 void *destscr; |
768 void *destscr; | 770 int destpitch; |
771 | |
772 if (GEM_bufops & B2S_C2P_1TOS) { | |
769 int destx; | 773 int destx; |
770 | 774 |
771 destscr = VDI_screen; | 775 destscr = VDI_screen; |
772 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); | 776 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); |
773 destx = (VDI_w - surface->w) >> 1; | 777 destx = (VDI_w - surface->w) >> 1; |
774 destx &= ~15; | 778 destx &= ~15; |
775 destscr += destx; | 779 destscr += destx; |
776 | 780 destpitch = VDI_pitch; |
777 for (i=0;i<numrects;i++) { | 781 } else { |
778 void *source,*destination; | 782 destscr = GEM_buffer2; |
779 int x1,x2; | 783 destpitch = surface->pitch; |
780 | 784 } |
781 x1 = rects[i].x & ~15; | 785 |
782 x2 = rects[i].x+rects[i].w; | 786 for (i=0;i<numrects;i++) { |
783 if (x2 & 15) { | 787 void *source,*destination; |
784 x2 = (x2 | 15) +1; | 788 int x1,x2; |
785 } | 789 |
786 | 790 x1 = rects[i].x & ~15; |
787 source = surface->pixels; | 791 x2 = rects[i].x+rects[i].w; |
788 source += surface->pitch * rects[i].y; | 792 if (x2 & 15) { |
789 source += x1; | 793 x2 = (x2 | 15) +1; |
790 | |
791 destination = destscr; | |
792 destination += VDI_pitch * rects[i].y; | |
793 destination += x1; | |
794 | |
795 /* Convert chunky to planar screen */ | |
796 Atari_C2pConvert( | |
797 source, | |
798 destination, | |
799 x2-x1, | |
800 rects[i].h, | |
801 SDL_FALSE, | |
802 surface->pitch, | |
803 VDI_pitch | |
804 ); | |
805 | |
806 } | 794 } |
807 | 795 |
808 return; | 796 source = surface->pixels; |
809 } | 797 source += surface->pitch * rects[i].y; |
810 | 798 source += x1; |
811 if (!(surface->flags & SDL_DOUBLEBUF)) { | 799 |
812 return; | 800 destination = destscr; |
813 } | 801 destination += destpitch * rects[i].y; |
814 } | 802 destination += x1; |
815 | 803 |
816 mfdb_src.fd_addr=surface->pixels; | 804 SDL_Atari_C2pConvert( |
817 mfdb_src.fd_w=surface->w; | 805 source, destination, |
818 mfdb_src.fd_h=surface->h; | 806 x2-x1, rects[i].h, |
819 mfdb_src.fd_wdwidth=(surface->w) >> 4; | 807 SDL_FALSE, |
820 mfdb_src.fd_stand=0; | 808 surface->pitch, destpitch |
821 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 809 ); |
822 mfdb_src.fd_r1=0; | 810 } |
823 mfdb_src.fd_r2=0; | 811 } |
824 mfdb_src.fd_r3=0; | 812 |
825 | 813 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { |
826 for ( i=0; i<numrects; ++i ) { | 814 MFDB mfdb_src; |
827 blitcoords[0] = rects[i].x; | 815 short blitcoords[8]; |
828 blitcoords[1] = rects[i].y; | 816 |
829 blitcoords[2] = blitcoords[0] + rects[i].w - 1; | 817 mfdb_src.fd_addr=surface->pixels; |
830 blitcoords[3] = blitcoords[1] + rects[i].h - 1; | 818 mfdb_src.fd_w=surface->w; |
831 | 819 mfdb_src.fd_h=surface->h; |
832 blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1); | 820 mfdb_src.fd_wdwidth=(surface->w) >> 4; |
833 blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1); | 821 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; |
834 blitcoords[6] = blitcoords[4] + rects[i].w - 1; | 822 mfdb_src.fd_stand= |
835 blitcoords[7] = blitcoords[5] + rects[i].h - 1; | 823 mfdb_src.fd_r1= |
836 | 824 mfdb_src.fd_r2= |
837 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | 825 mfdb_src.fd_r3= 0; |
826 if (GEM_bufops & B2S_VROCPYFM_2TOS) { | |
827 mfdb_src.fd_addr=GEM_buffer2; | |
828 } | |
829 | |
830 for ( i=0; i<numrects; ++i ) { | |
831 blitcoords[0] = rects[i].x; | |
832 blitcoords[1] = rects[i].y; | |
833 blitcoords[2] = blitcoords[0] + rects[i].w - 1; | |
834 blitcoords[3] = blitcoords[1] + rects[i].h - 1; | |
835 | |
836 blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1); | |
837 blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1); | |
838 blitcoords[6] = blitcoords[4] + rects[i].w - 1; | |
839 blitcoords[7] = blitcoords[5] + rects[i].h - 1; | |
840 | |
841 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | |
842 } | |
838 } | 843 } |
839 } | 844 } |
840 | 845 |
841 static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects) | 846 static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects) |
842 { | 847 { |
843 short pxy[8], wind_pxy[8]; | 848 short pxy[4], wind_pxy[4]; |
844 int i; | 849 int i; |
845 | 850 |
846 wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); | 851 if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { |
852 return; | |
853 } | |
847 | 854 |
848 for ( i=0; i<numrects; ++i ) { | 855 for ( i=0; i<numrects; ++i ) { |
849 pxy[0] = wind_pxy[0] + rects[i].x; | 856 pxy[0] = wind_pxy[0] + rects[i].x; |
850 pxy[1] = wind_pxy[1] + rects[i].y; | 857 pxy[1] = wind_pxy[1] + rects[i].y; |
851 pxy[2] = rects[i].w; | 858 pxy[2] = rects[i].w; |
868 } | 875 } |
869 } | 876 } |
870 | 877 |
871 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) | 878 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) |
872 { | 879 { |
873 MFDB mfdb_src; | 880 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { |
874 short blitcoords[8]; | 881 void *destscr; |
875 | 882 int destpitch; |
876 if (VDI_screen) { | 883 |
877 if (VDI_format==VDI_FORMAT_INTER) { | 884 if (GEM_bufops & B2S_C2P_1TOS) { |
878 void *destscr; | |
879 int destx; | 885 int destx; |
880 | 886 |
881 /* Center on destination screen */ | |
882 destscr = VDI_screen; | 887 destscr = VDI_screen; |
883 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); | 888 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); |
884 destx = (VDI_w - surface->w) >> 1; | 889 destx = (VDI_w - surface->w) >> 1; |
885 destx &= ~15; | 890 destx &= ~15; |
886 destscr += destx; | 891 destscr += destx; |
887 | 892 destpitch = VDI_pitch; |
888 /* Convert chunky to planar screen */ | 893 } else { |
889 Atari_C2pConvert( | 894 destscr = GEM_buffer2; |
890 surface->pixels, | 895 destpitch = surface->pitch; |
891 destscr, | 896 } |
892 surface->w, | 897 |
893 surface->h, | 898 SDL_Atari_C2pConvert( |
894 SDL_FALSE, | 899 surface->pixels, destscr, |
895 surface->pitch, | 900 surface->w, surface->h, |
896 VDI_pitch | 901 SDL_FALSE, |
897 ); | 902 surface->pitch, destpitch |
898 | 903 ); |
899 return(0); | 904 } |
900 } | 905 |
901 | 906 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { |
902 if (!(surface->flags & SDL_DOUBLEBUF)) { | 907 MFDB mfdb_src; |
903 return(0); | 908 short blitcoords[8]; |
904 } | 909 |
905 } | 910 mfdb_src.fd_w=surface->w; |
906 | 911 mfdb_src.fd_h=surface->h; |
907 mfdb_src.fd_addr=surface->pixels; | 912 mfdb_src.fd_wdwidth=(surface->w) >> 4; |
908 mfdb_src.fd_w=surface->w; | 913 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; |
909 mfdb_src.fd_h=surface->h; | 914 mfdb_src.fd_stand= |
910 mfdb_src.fd_wdwidth=(surface->w) >> 4; | 915 mfdb_src.fd_r1= |
911 mfdb_src.fd_stand=0; | 916 mfdb_src.fd_r2= |
912 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 917 mfdb_src.fd_r3= 0; |
913 mfdb_src.fd_r1=0; | 918 if (GEM_bufops & B2S_VROCPYFM_1TOS) { |
914 mfdb_src.fd_r2=0; | 919 mfdb_src.fd_addr=surface->pixels; |
915 mfdb_src.fd_r3=0; | 920 } else { |
916 | 921 mfdb_src.fd_addr=GEM_buffer2; |
917 blitcoords[0] = 0; | 922 } |
918 blitcoords[1] = 0; | 923 |
919 blitcoords[2] = surface->w - 1; | 924 blitcoords[0] = 0; |
920 blitcoords[3] = surface->h - 1; | 925 blitcoords[1] = 0; |
921 blitcoords[4] = (VDI_w - surface->w) >> 1; | 926 blitcoords[2] = surface->w - 1; |
922 blitcoords[5] = (VDI_h - surface->h) >> 1; | 927 blitcoords[3] = surface->h - 1; |
923 blitcoords[6] = blitcoords[4] + surface->w - 1; | 928 |
924 blitcoords[7] = blitcoords[5] + surface->h - 1; | 929 blitcoords[4] = (VDI_w - surface->w) >> 1; |
925 | 930 blitcoords[5] = (VDI_h - surface->h) >> 1; |
926 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | 931 blitcoords[6] = blitcoords[4] + surface->w - 1; |
932 blitcoords[7] = blitcoords[5] + surface->h - 1; | |
933 | |
934 vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | |
935 } | |
927 | 936 |
928 return(0); | 937 return(0); |
929 } | 938 } |
930 | 939 |
931 static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface) | 940 static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface) |
952 static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 961 static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) |
953 { | 962 { |
954 int i; | 963 int i; |
955 SDL_Surface *surface; | 964 SDL_Surface *surface; |
956 | 965 |
966 #ifdef DEBUG_VIDEO_GEM | |
967 printf("sdl:video:gem: setcolors()\n"); | |
968 #endif | |
969 | |
957 /* Do not change palette in True Colour */ | 970 /* Do not change palette in True Colour */ |
958 surface = this->screen; | 971 surface = this->screen; |
959 if (surface->format->BitsPerPixel > 8) { | 972 if (surface->format->BitsPerPixel > 8) { |
960 return 1; | 973 return 1; |
961 } | 974 } |
1042 wind_update(BEG_UPDATE); | 1055 wind_update(BEG_UPDATE); |
1043 | 1056 |
1044 v_hide_c(VDI_handle); | 1057 v_hide_c(VDI_handle); |
1045 | 1058 |
1046 /* Browse the rectangle list to redraw */ | 1059 /* Browse the rectangle list to redraw */ |
1047 wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]); | 1060 if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) { |
1048 | 1061 |
1049 while (todo[2] && todo[3]) { | 1062 while (todo[2] && todo[3]) { |
1050 | 1063 |
1051 if (rc_intersect((GRECT *)inside,(GRECT *)todo)) { | 1064 if (rc_intersect((GRECT *)inside,(GRECT *)todo)) { |
1052 todo[2] += todo[0]-1; | 1065 todo[2] += todo[0]-1; |
1053 todo[3] += todo[1]-1; | 1066 todo[3] += todo[1]-1; |
1054 refresh_window(this, winhandle, todo); | 1067 refresh_window(this, winhandle, todo); |
1055 } | 1068 } |
1056 | 1069 |
1057 wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]); | 1070 if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) { |
1071 break; | |
1072 } | |
1073 } | |
1074 | |
1058 } | 1075 } |
1059 | 1076 |
1060 /* Update finished */ | 1077 /* Update finished */ |
1061 wind_update(END_UPDATE); | 1078 wind_update(END_UPDATE); |
1062 | 1079 |
1063 v_show_c(VDI_handle,1); | 1080 v_show_c(VDI_handle,1); |
1081 | |
1082 #if DEBUG_VIDEO_GEM | |
1083 fflush(stdout); | |
1084 #endif | |
1064 } | 1085 } |
1065 | 1086 |
1066 static void refresh_window(_THIS, int winhandle, short *rect) | 1087 static void refresh_window(_THIS, int winhandle, short *rect) |
1067 { | 1088 { |
1068 MFDB mfdb_src; | 1089 MFDB mfdb_src; |
1069 short pxy[8], wind_pxy[8]; | 1090 short pxy[8],wind_pxy[8]; |
1091 SDL_Surface *surface; | |
1070 int iconified; | 1092 int iconified; |
1071 SDL_Surface *surface; | |
1072 | |
1073 surface=this->screen; | |
1074 | 1093 |
1075 /* Is window iconified ? */ | 1094 /* Is window iconified ? */ |
1076 iconified = 0; | 1095 iconified = 0; |
1077 if (GEM_wfeatures & (1<<WF_ICONIFY)) { | 1096 /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ { |
1078 wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); | 1097 if (wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])!=0) { |
1079 iconified = pxy[0]; | 1098 iconified = wind_pxy[0]; |
1080 } | 1099 } |
1081 | 1100 } |
1082 wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); | 1101 |
1083 | 1102 if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { |
1084 if (iconified) { | 1103 return; |
1085 /* Refresh icon */ | 1104 } |
1086 mfdb_src.fd_addr=surface->pixels; /* Should be icon image */ | 1105 |
1087 mfdb_src.fd_w=surface->w; | 1106 if (iconified && GEM_icon) { |
1088 mfdb_src.fd_h=surface->h; | 1107 short icon_rect[4], dst_rect[4]; |
1089 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; | 1108 |
1090 mfdb_src.fd_stand=0; | 1109 surface = GEM_icon; |
1091 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 1110 |
1092 mfdb_src.fd_r1=0; | 1111 GEM_ClearRect(this, rect); |
1093 mfdb_src.fd_r2=0; | 1112 |
1094 mfdb_src.fd_r3=0; | 1113 /* Calculate centered icon(x,y,w,h) relative to window */ |
1114 icon_rect[0] = (wind_pxy[2]-surface->w)>>1; | |
1115 icon_rect[1] = (wind_pxy[3]-surface->h)>>1; | |
1116 icon_rect[2] = surface->w; | |
1117 icon_rect[3] = surface->h; | |
1118 | |
1119 /* Calculate redraw rectangle(x,y,w,h) relative to window */ | |
1120 dst_rect[0] = rect[0]-wind_pxy[0]; | |
1121 dst_rect[1] = rect[1]-wind_pxy[1]; | |
1122 dst_rect[2] = rect[2]-rect[0]+1; | |
1123 dst_rect[3] = rect[3]-rect[1]+1; | |
1124 | |
1125 /* Does the icon rectangle must be redrawn ? */ | |
1126 if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) { | |
1127 return; | |
1128 } | |
1129 | |
1130 #ifdef DEBUG_VIDEO_GEM | |
1131 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", | |
1132 surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]); | |
1133 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", | |
1134 icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]); | |
1135 printf("sdl:video:gem: refresh_window(): draw icon\n"); | |
1136 #endif | |
1137 | |
1138 /* Calculate icon(x1,y1,x2,y2) relative to screen */ | |
1139 icon_rect[0] += wind_pxy[0]; | |
1140 icon_rect[1] += wind_pxy[1]; | |
1141 icon_rect[2] += icon_rect[0]-1; | |
1142 icon_rect[3] += icon_rect[1]-1; | |
1143 | |
1144 /* Calculate intersection rectangle to redraw */ | |
1145 pxy[0]=0; | |
1146 pxy[1]=0; | |
1147 pxy[2]=surface->w - 1; | |
1148 pxy[3]=surface->h - 1; | |
1149 pxy[4]=rect[0]; | |
1150 pxy[5]=rect[1]; | |
1151 pxy[6]=rect[2]; | |
1152 pxy[7]=rect[3]; | |
1153 | |
1154 if (icon_rect[0]>rect[0]) { | |
1155 pxy[4]=icon_rect[0]; | |
1156 } else if (icon_rect[0]<rect[0]) { | |
1157 pxy[0]=rect[0]-icon_rect[0]; | |
1158 } | |
1159 | |
1160 if (icon_rect[1]>rect[1]) { | |
1161 pxy[5]=icon_rect[1]; | |
1162 } else if (icon_rect[1]<rect[1]) { | |
1163 pxy[1]=rect[1]-icon_rect[1]; | |
1164 } | |
1165 | |
1166 if (icon_rect[2]>rect[2]) { | |
1167 pxy[2]=rect[2]-icon_rect[0]; | |
1168 pxy[6]=rect[2]; | |
1169 } else if (icon_rect[2]<rect[2]) { | |
1170 pxy[2]=icon_rect[2]-rect[0]; | |
1171 pxy[6]=icon_rect[2]; | |
1172 } | |
1173 | |
1174 if (icon_rect[3]>rect[3]) { | |
1175 pxy[3]=rect[3]-icon_rect[1]; | |
1176 pxy[7]=rect[3]; | |
1177 } else if (icon_rect[3]<rect[3]) { | |
1178 pxy[3]=icon_rect[3]-rect[1]; | |
1179 pxy[7]=icon_rect[3]; | |
1180 } | |
1181 | |
1095 } else { | 1182 } else { |
1096 /* Refresh window */ | 1183 surface = this->screen; |
1097 mfdb_src.fd_addr=surface->pixels; | 1184 |
1098 mfdb_src.fd_w=surface->w; | 1185 #ifdef DEBUG_VIDEO_GEM |
1099 mfdb_src.fd_h=surface->h; | 1186 printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); |
1100 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; | 1187 #endif |
1101 mfdb_src.fd_stand=0; | 1188 |
1102 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | 1189 /* Redraw all window content */ |
1103 mfdb_src.fd_r1=0; | 1190 pxy[0] = rect[0]-wind_pxy[0]; |
1104 mfdb_src.fd_r2=0; | 1191 pxy[1] = rect[1]-wind_pxy[1]; |
1105 mfdb_src.fd_r3=0; | 1192 pxy[2] = rect[2]-wind_pxy[0]; |
1106 } | 1193 pxy[3] = rect[3]-wind_pxy[1]; |
1107 | 1194 |
1108 pxy[0] = rect[0] - wind_pxy[0]; | 1195 pxy[4] = rect[0]; |
1109 pxy[1] = rect[1] - wind_pxy[1]; | 1196 pxy[5] = rect[1]; |
1110 pxy[2] = pxy[0] + rect[2] - rect[0]; | 1197 pxy[6] = rect[2]; |
1111 pxy[3] = pxy[1] + rect[3] - rect[1]; | 1198 pxy[7] = rect[3]; |
1112 | 1199 } |
1113 pxy[4] = rect[0]; | 1200 |
1114 pxy[5] = rect[1]; | 1201 if (GEM_bufops & B2S_C2P_1TO2) { |
1115 pxy[6] = rect[2]; | 1202 void *src, *dest; |
1116 pxy[7] = rect[3]; | 1203 int x1,x2; |
1204 | |
1205 x1 = (rect[0]-wind_pxy[0]) & ~15; | |
1206 x2 = rect[2]-wind_pxy[0]; | |
1207 if (x2 & 15) { | |
1208 x2 = (x2 | 15) +1; | |
1209 } | |
1210 | |
1211 src = surface->pixels; | |
1212 src += surface->pitch * (rect[1]-wind_pxy[1]); | |
1213 src += x1; | |
1214 | |
1215 dest = GEM_buffer2; | |
1216 dest += surface->pitch * (rect[1]-wind_pxy[1]); | |
1217 dest += x1; | |
1218 | |
1219 SDL_Atari_C2pConvert( | |
1220 src, dest, | |
1221 x2-x1, rect[3]-rect[1]+1, | |
1222 SDL_FALSE, | |
1223 surface->pitch, surface->pitch | |
1224 ); | |
1225 } | |
1226 | |
1227 mfdb_src.fd_addr=surface->pixels; | |
1228 mfdb_src.fd_w=surface->w; | |
1229 mfdb_src.fd_h=surface->h; | |
1230 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | |
1231 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; | |
1232 mfdb_src.fd_stand= | |
1233 mfdb_src.fd_r1= | |
1234 mfdb_src.fd_r2= | |
1235 mfdb_src.fd_r3= 0; | |
1236 | |
1237 if (GEM_bufops & B2S_VROCPYFM_2TOS) { | |
1238 mfdb_src.fd_addr=GEM_buffer2; | |
1239 } | |
1240 | |
1241 #ifdef DEBUG_VIDEO_GEM | |
1242 printf("sdl:video:gem: redraw (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", | |
1243 pxy[0],pxy[1],pxy[2],pxy[3], | |
1244 pxy[4],pxy[5],pxy[6],pxy[7] | |
1245 ); | |
1246 #endif | |
1117 | 1247 |
1118 vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); | 1248 vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); |
1119 } | 1249 } |