comparison src/video/gem/SDL_gemvideo.c @ 799:85960507bd2e

Bugfixes: some info about current framebuffer overwritten by some default values, and screen width must be multiple of 16 pixels to work correctly
author Patrice Mandin <patmandin@gmail.com>
date Fri, 06 Feb 2004 22:41:00 +0000
parents b8d311d90021
children 60a4293ffea9
comparison
equal deleted inserted replaced
798:f1b029d3b301 799:85960507bd2e
61 #include "SDL_gemwm_c.h" 61 #include "SDL_gemwm_c.h"
62 #include "SDL_xbiosevents_c.h" 62 #include "SDL_xbiosevents_c.h"
63 63
64 /* Defines */ 64 /* Defines */
65 65
66 /*#define DEBUG_VIDEO_GEM 1*/ 66 #define DEBUG_VIDEO_GEM 0
67 67
68 #define GEM_VID_DRIVER_NAME "gem" 68 #define GEM_VID_DRIVER_NAME "gem"
69 69
70 #undef MIN 70 #undef MIN
71 #define MIN(a,b) (((a)<(b)) ? (a) : (b)) 71 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
215 */ 215 */
216 if (EdDI_version >= EDDI_11) { 216 if (EdDI_version >= EDDI_11) {
217 VDI_pitch = work_out[5]; 217 VDI_pitch = work_out[5];
218 VDI_screen = (void *) *((unsigned long *) &work_out[6]); 218 VDI_screen = (void *) *((unsigned long *) &work_out[6]);
219 219
220 #if 0 /* lecoat */
220 switch(num_colours) { 221 switch(num_colours) {
221 case 32768UL: 222 case 32768UL:
222 if (work_out[14] & (1<<7)) { 223 if (work_out[14] & (1<<7)) {
223 /* Little endian */ 224 /* Little endian */
224 if (work_out[14] & (1<<1)) { 225 if (work_out[14] & (1<<1)) {
266 break; 267 break;
267 } 268 }
268 } 269 }
269 break; 270 break;
270 } 271 }
272 #endif
271 } 273 }
272 274
273 switch(clut_type) { 275 switch(clut_type) {
274 case VDI_CLUT_HARDWARE: 276 case VDI_CLUT_HARDWARE:
275 { 277 {
282 vdi_index[*tmp_p++] = i; 284 vdi_index[*tmp_p++] = i;
283 } 285 }
284 } 286 }
285 break; 287 break;
286 case VDI_CLUT_SOFTWARE: 288 case VDI_CLUT_SOFTWARE:
287 if (EdDI_version < EDDI_11) { 289 /* lecoat if (EdDI_version < EDDI_11) */ {
288 int component; /* red, green, blue, alpha, overlay */ 290 int component; /* red, green, blue, alpha, overlay */
289 int num_bit; 291 int num_bit;
290 unsigned short *tmp_p; 292 unsigned short *tmp_p;
291 293
292 /* We can build masks with info here */ 294 /* We can build masks with info here */
452 GEM_handle = -1; 454 GEM_handle = -1;
453 GEM_locked = SDL_FALSE; 455 GEM_locked = SDL_FALSE;
454 GEM_win_fulled = SDL_FALSE; 456 GEM_win_fulled = SDL_FALSE;
455 457
456 VDI_screen = NULL; 458 VDI_screen = NULL;
459 #if 1 /* lecoat */
460 VDI_pitch = VDI_w * VDI_pixelsize;
461 VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
462 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
463 VDI_ReadExtInfo(this, work_out);
464 #else
457 VDI_ReadExtInfo(this, work_out); 465 VDI_ReadExtInfo(this, work_out);
458 if (VDI_screen == NULL) { 466 if (VDI_screen == NULL) {
459 VDI_pitch = VDI_w * VDI_pixelsize; 467 VDI_pitch = VDI_w * VDI_pixelsize;
460 VDI_format = VDI_FORMAT_PACK; 468 VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
461 if (VDI_bpp <= 8) {
462 VDI_format = VDI_FORMAT_INTER;
463 }
464 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; 469 VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
465 } 470 }
471 #endif
472
473 #ifdef DEBUG_VIDEO_GEM
474 printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch);
475 printf("sdl:video:gem: format=%d\n", VDI_format);
476 printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
477 VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask
478 );
479 #endif
466 480
467 /* Setup destination mfdb */ 481 /* Setup destination mfdb */
468 VDI_dst_mfdb.fd_addr = NULL; 482 VDI_dst_mfdb.fd_addr = NULL;
469 483
470 /* Update hardware info */ 484 /* Update hardware info */
596 /* Windowed mode */ 610 /* Windowed mode */
597 maxwidth=GEM_desk_w; 611 maxwidth=GEM_desk_w;
598 maxheight=GEM_desk_h; 612 maxheight=GEM_desk_h;
599 } 613 }
600 614
615 /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
616 if ((width & -16) != 0) {
617 width = (width | 15) +1;
618 }
619
601 if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) { 620 if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
602 SDL_SetError("Couldn't find requested mode in list"); 621 SDL_SetError("Couldn't find requested mode in list");
603 return(NULL); 622 return(NULL);
604 } 623 }
605 624
608 SDL_SetError("Couldn't allocate new pixel format for requested mode"); 627 SDL_SetError("Couldn't allocate new pixel format for requested mode");
609 return(NULL); 628 return(NULL);
610 } 629 }
611 630
612 screensize = width * height * VDI_pixelsize; 631 screensize = width * height * VDI_pixelsize;
632
633 #ifdef DEBUG_VIDEO_GEM
634 printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize);
635 #endif
613 636
614 /*--- Allocate shadow buffers if needed, and conversion operations ---*/ 637 /*--- Allocate shadow buffers if needed, and conversion operations ---*/
615 GEM_bufops=0; 638 GEM_bufops=0;
616 use_shadow1=use_shadow2=SDL_FALSE; 639 use_shadow1=use_shadow2=SDL_FALSE;
617 if (VDI_screen && (flags & SDL_FULLSCREEN)) { 640 if (VDI_screen && (flags & SDL_FULLSCREEN)) {
728 current->flags = modeflags; 751 current->flags = modeflags;
729 current->w = width; 752 current->w = width;
730 current->h = height; 753 current->h = height;
731 if (use_shadow1) { 754 if (use_shadow1) {
732 current->pixels = GEM_buffer1; 755 current->pixels = GEM_buffer1;
733 current->pitch = width * (VDI_bpp >> 3); 756 current->pitch = width * VDI_pixelsize;
734 } else { 757 } else {
735 current->pixels = VDI_screen; 758 current->pixels = VDI_screen;
736 current->pixels += VDI_pitch * ((VDI_h - height) >> 1); 759 current->pixels += VDI_pitch * ((VDI_h - height) >> 1);
737 current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1); 760 current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1);
738 current->pitch = VDI_pitch; 761 current->pitch = VDI_pitch;
739 } 762 }
740 763
764 #ifdef DEBUG_VIDEO_GEM
765 printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h);
766 #endif
767
741 this->UpdateRects = GEM_UpdateRects; 768 this->UpdateRects = GEM_UpdateRects;
742 769
743 /* We're done */ 770 /* We're done */
744 return(current); 771 return(current);
745 } 772 }
764 } 791 }
765 792
766 static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) 793 static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)
767 { 794 {
768 SDL_Surface *surface; 795 SDL_Surface *surface;
769 int i; 796 int i, surf_width;
770 797
771 surface = this->screen; 798 surface = this->screen;
799 /* Need to be a multiple of 16 pixels */
800 surf_width=surface->w;
801 if ((surf_width & -16) != 0) {
802 surf_width = (surf_width | 15) + 1;
803 }
772 804
773 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { 805 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
774 void *destscr; 806 void *destscr;
775 int destpitch; 807 int destpitch;
776 808
777 if (GEM_bufops & B2S_C2P_1TOS) { 809 if (GEM_bufops & B2S_C2P_1TOS) {
778 int destx; 810 int destx;
779 811
780 destscr = VDI_screen; 812 destscr = VDI_screen;
781 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); 813 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
782 destx = (VDI_w - surface->w) >> 1; 814 destx = (VDI_w - surf_width) >> 1;
783 destx &= ~15; 815 destx &= ~15;
784 destscr += destx; 816 destscr += destx;
785 destpitch = VDI_pitch; 817 destpitch = VDI_pitch;
786 } else { 818 } else {
787 destscr = GEM_buffer2; 819 destscr = GEM_buffer2;
818 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { 850 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
819 MFDB mfdb_src; 851 MFDB mfdb_src;
820 short blitcoords[8]; 852 short blitcoords[8];
821 853
822 mfdb_src.fd_addr=surface->pixels; 854 mfdb_src.fd_addr=surface->pixels;
823 mfdb_src.fd_w=surface->w; 855 mfdb_src.fd_w=surf_width;
824 mfdb_src.fd_h=surface->h; 856 mfdb_src.fd_h=surface->h;
825 mfdb_src.fd_wdwidth=(surface->w) >> 4; 857 mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4;
826 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; 858 mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
827 mfdb_src.fd_stand= 859 mfdb_src.fd_stand=
828 mfdb_src.fd_r1= 860 mfdb_src.fd_r1=
829 mfdb_src.fd_r2= 861 mfdb_src.fd_r2=
830 mfdb_src.fd_r3= 0; 862 mfdb_src.fd_r3= 0;
880 } 912 }
881 } 913 }
882 914
883 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) 915 static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
884 { 916 {
917 int surf_width;
918
919 /* Need to be a multiple of 16 pixels */
920 surf_width=surface->w;
921 if ((surf_width & -16) != 0) {
922 surf_width = (surf_width | 15) + 1;
923 }
924
885 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { 925 if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
886 void *destscr; 926 void *destscr;
887 int destpitch; 927 int destpitch;
888 928
889 if (GEM_bufops & B2S_C2P_1TOS) { 929 if (GEM_bufops & B2S_C2P_1TOS) {
890 int destx; 930 int destx;
891 931
892 destscr = VDI_screen; 932 destscr = VDI_screen;
893 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); 933 destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
894 destx = (VDI_w - surface->w) >> 1; 934 destx = (VDI_w - surf_width) >> 1;
895 destx &= ~15; 935 destx &= ~15;
896 destscr += destx; 936 destscr += destx;
897 destpitch = VDI_pitch; 937 destpitch = VDI_pitch;
898 } else { 938 } else {
899 destscr = GEM_buffer2; 939 destscr = GEM_buffer2;
900 destpitch = surface->pitch; 940 destpitch = surface->pitch;
901 } 941 }
902 942
903 SDL_Atari_C2pConvert( 943 SDL_Atari_C2pConvert(
904 surface->pixels, destscr, 944 surface->pixels, destscr,
905 surface->w, surface->h, 945 surf_width, surface->h,
906 SDL_FALSE, 946 SDL_FALSE,
907 surface->pitch, destpitch 947 surface->pitch, destpitch
908 ); 948 );
909 } 949 }
910 950
911 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { 951 if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
912 MFDB mfdb_src; 952 MFDB mfdb_src;
913 short blitcoords[8]; 953 short blitcoords[8];
914 954
915 mfdb_src.fd_w=surface->w; 955 mfdb_src.fd_w=surf_width;
916 mfdb_src.fd_h=surface->h; 956 mfdb_src.fd_h=surface->h;
917 mfdb_src.fd_wdwidth=(surface->w) >> 4; 957 mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4;
918 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; 958 mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
919 mfdb_src.fd_stand= 959 mfdb_src.fd_stand=
920 mfdb_src.fd_r1= 960 mfdb_src.fd_r1=
921 mfdb_src.fd_r2= 961 mfdb_src.fd_r2=
922 mfdb_src.fd_r3= 0; 962 mfdb_src.fd_r3= 0;
1082 /* Update finished */ 1122 /* Update finished */
1083 wind_update(END_UPDATE); 1123 wind_update(END_UPDATE);
1084 1124
1085 v_show_c(VDI_handle,1); 1125 v_show_c(VDI_handle,1);
1086 1126
1087 #if DEBUG_VIDEO_GEM 1127 #if 0 /*DEBUG_VIDEO_GEM*/
1088 fflush(stdout); 1128 fflush(stdout);
1089 #endif 1129 #endif
1090 } 1130 }
1091 1131
1092 static void refresh_window(_THIS, int winhandle, short *rect) 1132 static void refresh_window(_THIS, int winhandle, short *rect)
1134 /* Does the icon rectangle must be redrawn ? */ 1174 /* Does the icon rectangle must be redrawn ? */
1135 if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) { 1175 if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) {
1136 return; 1176 return;
1137 } 1177 }
1138 1178
1139 #ifdef DEBUG_VIDEO_GEM 1179 #if DEBUG_VIDEO_GEM
1140 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", 1180 printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n",
1141 surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]); 1181 surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]);
1142 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", 1182 printf("sdl:video:gem: icon(%d,%d,%d,%d)\n",
1143 icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]); 1183 icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]);
1144 printf("sdl:video:gem: refresh_window(): draw icon\n"); 1184 printf("sdl:video:gem: refresh_window(): draw icon\n");
1163 pxy[3] -= wind_pxy[1]+icony; 1203 pxy[3] -= wind_pxy[1]+icony;
1164 1204
1165 } else { 1205 } else {
1166 surface = this->screen; 1206 surface = this->screen;
1167 1207
1168 #ifdef DEBUG_VIDEO_GEM 1208 #if DEBUG_VIDEO_GEM
1169 printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); 1209 printf("sdl:video:gem: refresh_window(): draw frame buffer\n");
1170 #endif 1210 #endif
1171 1211
1172 /* Redraw all window content */ 1212 /* Redraw all window content */
1173 pxy[0] = rect[0]-wind_pxy[0]; 1213 pxy[0] = rect[0]-wind_pxy[0];
1206 surface->pitch, surface->pitch 1246 surface->pitch, surface->pitch
1207 ); 1247 );
1208 } 1248 }
1209 1249
1210 mfdb_src.fd_addr=surface->pixels; 1250 mfdb_src.fd_addr=surface->pixels;
1211 mfdb_src.fd_w=surface->w; 1251 {
1252 int width;
1253
1254 /* Need to be a multiple of 16 pixels */
1255 width=surface->w;
1256 if ((width & -16) != 0) {
1257 width = (width | 15) + 1;
1258 }
1259 mfdb_src.fd_w=width;
1260 }
1212 mfdb_src.fd_h=surface->h; 1261 mfdb_src.fd_h=surface->h;
1213 mfdb_src.fd_nplanes=surface->format->BitsPerPixel; 1262 mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
1214 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; 1263 mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
1215 mfdb_src.fd_stand= 1264 mfdb_src.fd_stand=
1216 mfdb_src.fd_r1= 1265 mfdb_src.fd_r1=
1219 1268
1220 if (GEM_bufops & B2S_VROCPYFM_2TOS) { 1269 if (GEM_bufops & B2S_VROCPYFM_2TOS) {
1221 mfdb_src.fd_addr=GEM_buffer2; 1270 mfdb_src.fd_addr=GEM_buffer2;
1222 } 1271 }
1223 1272
1224 #ifdef DEBUG_VIDEO_GEM 1273 #if DEBUG_VIDEO_GEM
1225 printf("sdl:video:gem: redraw (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", 1274 printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n",
1275 surface->w, surface->h,
1226 pxy[0],pxy[1],pxy[2],pxy[3], 1276 pxy[0],pxy[1],pxy[2],pxy[3],
1227 pxy[4],pxy[5],pxy[6],pxy[7] 1277 pxy[4],pxy[5],pxy[6],pxy[7]
1228 ); 1278 );
1229 #endif 1279 #endif
1230 1280