comparison src/video/xbios/SDL_xbios.c @ 4198:6405314a7c07 SDL-1.2

Define flags for double line and c2p operations. More Milan video work.
author Patrice Mandin <patmandin@gmail.com>
date Sun, 20 Sep 2009 12:08:51 +0000
parents 1bf6585720e9
children 4c92a3d196f1
comparison
equal deleted inserted replaced
4197:1bf6585720e9 4198:6405314a7c07
96 static unsigned long F30_palette[256]; 96 static unsigned long F30_palette[256];
97 97
98 /* Default list of video modes */ 98 /* Default list of video modes */
99 99
100 static const xbiosmode_t stmodes[1]={ 100 static const xbiosmode_t stmodes[1]={
101 {ST_LOW>>8,320,200,4,SDL_FALSE} 101 {ST_LOW>>8,320,200,4, XBIOSMODE_C2P}
102 }; 102 };
103 103
104 static const xbiosmode_t ttmodes[2]={ 104 static const xbiosmode_t ttmodes[2]={
105 {TT_LOW,320,480,8,SDL_FALSE}, 105 {TT_LOW,320,480,8, XBIOSMODE_C2P},
106 {TT_LOW,320,240,8,SDL_TRUE} /* Software double-lined mode */ 106 {TT_LOW,320,240,8, XBIOSMODE_C2P|XBIOSMODE_DOUBLELINE}
107 }; 107 };
108 108
109 static const xbiosmode_t falconrgbmodes[16]={ 109 static const xbiosmode_t falconrgbmodes[16]={
110 {BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE}, 110 {BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,0},
111 {BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE}, 111 {BPS16|COL80|OVERSCAN,768,240,16,0},
112 {BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE}, 112 {BPS16|COL80|VERTFLAG,640,400,16,0},
113 {BPS16|COL80,640,200,16,SDL_FALSE}, 113 {BPS16|COL80,640,200,16,0},
114 {BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE}, 114 {BPS16|OVERSCAN|VERTFLAG,384,480,16,0},
115 {BPS16|OVERSCAN,384,240,16,SDL_FALSE}, 115 {BPS16|OVERSCAN,384,240,16,0},
116 {BPS16|VERTFLAG,320,400,16,SDL_FALSE}, 116 {BPS16|VERTFLAG,320,400,16,0},
117 {BPS16,320,200,16,SDL_FALSE}, 117 {BPS16,320,200,16,0},
118 {BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE}, 118 {BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,XBIOSMODE_C2P},
119 {BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE}, 119 {BPS8|COL80|OVERSCAN,768,240,8,XBIOSMODE_C2P},
120 {BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE}, 120 {BPS8|COL80|VERTFLAG,640,400,8,XBIOSMODE_C2P},
121 {BPS8|COL80,640,200,8,SDL_FALSE}, 121 {BPS8|COL80,640,200,8,XBIOSMODE_C2P},
122 {BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE}, 122 {BPS8|OVERSCAN|VERTFLAG,384,480,8,XBIOSMODE_C2P},
123 {BPS8|OVERSCAN,384,240,8,SDL_FALSE}, 123 {BPS8|OVERSCAN,384,240,8,XBIOSMODE_C2P},
124 {BPS8|VERTFLAG,320,400,8,SDL_FALSE}, 124 {BPS8|VERTFLAG,320,400,8,XBIOSMODE_C2P},
125 {BPS8,320,200,8,SDL_FALSE} 125 {BPS8,320,200,8,XBIOSMODE_C2P}
126 }; 126 };
127 127
128 static const xbiosmode_t falconvgamodes[6]={ 128 static const xbiosmode_t falconvgamodes[6]={
129 {BPS16,320,480,16,SDL_FALSE}, 129 {BPS16,320,480,16,0},
130 {BPS16|VERTFLAG,320,240,16,SDL_FALSE}, 130 {BPS16|VERTFLAG,320,240,16,0},
131 {BPS8|COL80,640,480,8,SDL_FALSE}, 131 {BPS8|COL80,640,480,8,XBIOSMODE_C2P},
132 {BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE}, 132 {BPS8|COL80|VERTFLAG,640,240,8,XBIOSMODE_C2P},
133 {BPS8,320,480,8,SDL_FALSE}, 133 {BPS8,320,480,8,XBIOSMODE_C2P},
134 {BPS8|VERTFLAG,320,240,8,SDL_FALSE} 134 {BPS8|VERTFLAG,320,240,8,XBIOSMODE_C2P}
135 }; 135 };
136 136
137 /* Xbios driver bootstrap functions */ 137 /* Xbios driver bootstrap functions */
138 138
139 static int XBIOS_Available(void) 139 static int XBIOS_Available(void)
490 SDL_XBIOS_ListBlowupModes(this, 0, (blow_cookie_t *)cookie_blow); 490 SDL_XBIOS_ListBlowupModes(this, 0, (blow_cookie_t *)cookie_blow);
491 } 491 }
492 } 492 }
493 break; 493 break;
494 case VDO_MILAN: 494 case VDO_MILAN:
495 SDL_XBIOS_ListMilanModes(this, 0); 495 {
496 SCREENINFO si;
497
498 /* Read infos about current mode */
499 VsetScreen(-1, &XBIOS_oldvmode, MI_MAGIC, CMD_GETMODE);
500 this->info.current_w = si.scrWidth;
501 this->info.current_h = si.scrHeight;
502
503 si.size = sizeof(SCREENINFO);
504 si.devID = XBIOS_oldvmode;
505 si.scrFlags = 0;
506 VsetScreen(-1, &si, MI_MAGIC, CMD_GETINFO);
507
508 XBIOS_oldnumcol = 0;
509 if (si.scrFlags & SCRINFO_OK) {
510 if (si.scrPlanes <= 8) {
511 XBIOS_oldnumcol = 1<<si.scrPlanes;
512 }
513 }
514 if (XBIOS_oldnumcol) {
515 VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
516 }
517
518 SDL_XBIOS_ListMilanModes(this, 0);
519 }
496 break; 520 break;
497 } 521 }
498 522
499 for ( i=0; i<NUM_MODELISTS; ++i ) { 523 for ( i=0; i<NUM_MODELISTS; ++i ) {
500 int j; 524 int j;
651 } 675 }
652 676
653 new_screen_size = width * height * ((new_depth)>>3); 677 new_screen_size = width * height * ((new_depth)>>3);
654 new_screen_size += 256; /* To align on a 256 byte adress */ 678 new_screen_size += 256; /* To align on a 256 byte adress */
655 679
656 if (new_depth == 8) { 680 if (new_video_mode->flags & XBIOSMODE_C2P) {
657 XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM); 681 XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM);
658 682
659 if (XBIOS_shadowscreen == NULL) { 683 if (XBIOS_shadowscreen == NULL) {
660 SDL_SetError("Can not allocate %d KB for shadow buffer", new_screen_size>>10); 684 SDL_SetError("Can not allocate %d KB for shadow buffer", new_screen_size>>10);
661 return (NULL); 685 return (NULL);
662 } 686 }
663 SDL_memset(XBIOS_shadowscreen, 0, new_screen_size); 687 SDL_memset(XBIOS_shadowscreen, 0, new_screen_size);
664 } 688 }
665 689
666 /* Output buffer needs to be twice in size for the software double-line mode */ 690 /* Output buffer needs to be twice in size for the software double-line mode */
667 XBIOS_doubleline = SDL_FALSE; 691 if (new_video_mode->flags & XBIOSMODE_DOUBLELINE) {
668 if (new_video_mode->doubleline) {
669 new_screen_size <<= 1; 692 new_screen_size <<= 1;
670 XBIOS_doubleline = SDL_TRUE;
671 } 693 }
672 694
673 /* Double buffer ? */ 695 /* Double buffer ? */
674 num_buffers = 1; 696 num_buffers = 1;
675 697
704 XBIOS_FreeBuffers(this); 726 XBIOS_FreeBuffers(this);
705 SDL_SetError("Couldn't allocate new pixel format for requested mode"); 727 SDL_SetError("Couldn't allocate new pixel format for requested mode");
706 return(NULL); 728 return(NULL);
707 } 729 }
708 730
709 current->w = XBIOS_width = width; 731 XBIOS_current = new_video_mode;
710 current->h = XBIOS_height = height; 732 current->w = width;
733 current->h = height;
711 current->pitch = (width * new_depth)>>3; 734 current->pitch = (width * new_depth)>>3;
712 735
713 /* this is for C2P conversion */ 736 /* this is for C2P conversion */
714 XBIOS_pitch = (new_video_mode->width * new_video_mode->depth)>>3; 737 XBIOS_pitch = (new_video_mode->width * new_video_mode->depth)>>3;
715 738
716 if (new_depth == 8) 739 if (new_video_mode->flags & XBIOSMODE_C2P)
717 current->pixels = XBIOS_shadowscreen; 740 current->pixels = XBIOS_shadowscreen;
718 else 741 else
719 current->pixels = XBIOS_screens[0]; 742 current->pixels = XBIOS_screens[0];
720 743
721 XBIOS_fbnum = 0; 744 XBIOS_fbnum = 0;
734 757
735 current->flags = modeflags; 758 current->flags = modeflags;
736 759
737 #ifndef DEBUG_VIDEO_XBIOS 760 #ifndef DEBUG_VIDEO_XBIOS
738 /* Now set the video mode */ 761 /* Now set the video mode */
739 Setscreen(-1,XBIOS_screens[0],-1); 762 if ((XBIOS_cvdo>>16) == VDO_MILAN) {
763 VsetScreen(-1, XBIOS_screens[0], MI_MAGIC, CMD_SETADR);
764 } else {
765 Setscreen(-1,XBIOS_screens[0],-1);
766 }
740 767
741 switch(XBIOS_cvdo >> 16) { 768 switch(XBIOS_cvdo >> 16) {
742 case VDO_ST: 769 case VDO_ST:
743 Setscreen(-1,-1,new_video_mode->number); 770 Setscreen(-1,-1,new_video_mode->number);
744 771
770 } else { 797 } else {
771 VsetMode(new_video_mode->number); 798 VsetMode(new_video_mode->number);
772 } 799 }
773 800
774 /* Set hardware palette to black in True Colour */ 801 /* Set hardware palette to black in True Colour */
775 if (new_depth == 16) { 802 if (new_depth > 8) {
776 SDL_memset(F30_palette, 0, sizeof(F30_palette)); 803 SDL_memset(F30_palette, 0, sizeof(F30_palette));
777 VsetRGB(0,256,F30_palette); 804 VsetRGB(0,256,F30_palette);
778 } 805 }
779 break; 806 break;
807 case VDO_MILAN:
808 /* Set hardware palette to black in True Colour */
809 if (new_depth > 8) {
810 SDL_memset(F30_palette, 0, sizeof(F30_palette));
811 VsetRGB(0,256,F30_palette);
812 }
813 break;
780 } 814 }
781 815
782 Vsync(); 816 Vsync();
783 #endif 817 #endif
784 818
812 { 846 {
813 SDL_Surface *surface; 847 SDL_Surface *surface;
814 848
815 surface = this->screen; 849 surface = this->screen;
816 850
817 if ((surface->format->BitsPerPixel) == 8) { 851 if (XBIOS_current->flags & XBIOSMODE_C2P) {
818 int i; 852 int i;
853 int doubleline = (XBIOS_current->flags & XBIOSMODE_DOUBLELINE ? 1 : 0);
819 854
820 for (i=0;i<numrects;i++) { 855 for (i=0;i<numrects;i++) {
821 void *source,*destination; 856 void *source,*destination;
822 int x1,x2; 857 int x1,x2;
823 858
839 SDL_Atari_C2pConvert( 874 SDL_Atari_C2pConvert(
840 source, 875 source,
841 destination, 876 destination,
842 x2-x1, 877 x2-x1,
843 rects[i].h, 878 rects[i].h,
844 XBIOS_doubleline, 879 doubleline,
845 surface->pitch, 880 surface->pitch,
846 XBIOS_pitch 881 XBIOS_pitch
847 ); 882 );
848 } 883 }
849 } 884 }
850 885
851 #ifndef DEBUG_VIDEO_XBIOS 886 #ifndef DEBUG_VIDEO_XBIOS
852 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); 887 if ((XBIOS_cvdo>>16) == VDO_MILAN) {
888 VsetScreen(-1, XBIOS_screens[XBIOS_fbnum], MI_MAGIC, CMD_SETADR);
889 } else {
890 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
891 }
853 892
854 Vsync(); 893 Vsync();
855 #endif 894 #endif
856 895
857 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { 896 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
858 XBIOS_fbnum ^= 1; 897 XBIOS_fbnum ^= 1;
859 if ((surface->format->BitsPerPixel) > 8) { 898 if ((XBIOS_current->flags & XBIOSMODE_C2P) == 0) {
860 surface->pixels=XBIOS_screens[XBIOS_fbnum]; 899 surface->pixels=XBIOS_screens[XBIOS_fbnum];
861 } 900 }
862 } 901 }
863 } 902 }
864 903
865 static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface) 904 static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
866 { 905 {
867 if ((surface->format->BitsPerPixel) == 8) { 906 if (XBIOS_current->flags & XBIOSMODE_C2P) {
868 void *destscr; 907 void *destscr;
869 int destx; 908 int destx;
909 int doubleline = (XBIOS_current->flags & XBIOSMODE_DOUBLELINE ? 1 : 0);
870 910
871 /* Center on destination screen */ 911 /* Center on destination screen */
872 destscr = XBIOS_screens[XBIOS_fbnum]; 912 destscr = XBIOS_screens[XBIOS_fbnum];
873 destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1); 913 destscr += XBIOS_pitch * ((XBIOS_current->height - surface->h) >> 1);
874 destx = (XBIOS_width - surface->w) >> 1; 914 destx = (XBIOS_current->width - surface->w) >> 1;
875 destx &= ~15; 915 destx &= ~15;
876 destscr += destx; 916 destscr += destx;
877 917
878 /* Convert chunky to planar screen */ 918 /* Convert chunky to planar screen */
879 SDL_Atari_C2pConvert( 919 SDL_Atari_C2pConvert(
880 surface->pixels, 920 surface->pixels,
881 destscr, 921 destscr,
882 surface->w, 922 surface->w,
883 surface->h, 923 surface->h,
884 XBIOS_doubleline, 924 doubleline,
885 surface->pitch, 925 surface->pitch,
886 XBIOS_pitch 926 XBIOS_pitch
887 ); 927 );
888 } 928 }
889 929
890 #ifndef DEBUG_VIDEO_XBIOS 930 #ifndef DEBUG_VIDEO_XBIOS
891 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); 931 if ((XBIOS_cvdo>>16) == VDO_MILAN) {
932 VsetScreen(-1, XBIOS_screens[XBIOS_fbnum], MI_MAGIC, CMD_SETADR);
933 } else {
934 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
935 }
892 936
893 Vsync(); 937 Vsync();
894 #endif 938 #endif
895 939
896 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { 940 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
897 XBIOS_fbnum ^= 1; 941 XBIOS_fbnum ^= 1;
898 if ((surface->format->BitsPerPixel) > 8) { 942 if ((XBIOS_current->flags & XBIOSMODE_C2P) == 0) {
899 surface->pixels=XBIOS_screens[XBIOS_fbnum]; 943 surface->pixels=XBIOS_screens[XBIOS_fbnum];
900 } 944 }
901 } 945 }
902 946
903 return(0); 947 return(0);
932 TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4); 976 TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4);
933 } 977 }
934 EsetPalette(firstcolor,ncolors,TT_palette); 978 EsetPalette(firstcolor,ncolors,TT_palette);
935 break; 979 break;
936 case VDO_F30: 980 case VDO_F30:
981 case VDO_MILAN:
937 for(i = 0; i < ncolors; i++) 982 for(i = 0; i < ncolors; i++)
938 { 983 {
939 r = colors[i].r; 984 r = colors[i].r;
940 v = colors[i].g; 985 v = colors[i].g;
941 b = colors[i].b; 986 b = colors[i].b;
985 } 1030 }
986 if (XBIOS_oldnumcol) { 1031 if (XBIOS_oldnumcol) {
987 VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette); 1032 VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
988 } 1033 }
989 break; 1034 break;
1035 case VDO_MILAN:
1036 VsetScreen(-1, &XBIOS_oldvmode, MI_MAGIC, CMD_SETMODE);
1037 if (XBIOS_oldnumcol) {
1038 VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
1039 }
1040 break;
990 } 1041 }
991 Vsync(); 1042 Vsync();
992 #endif 1043 #endif
993 1044
994 #if SDL_VIDEO_OPENGL 1045 #if SDL_VIDEO_OPENGL