comparison src/video/xbios/SDL_xbios.c @ 2036:12ef90a41631

Pfiou, all of it to update, faster to rewrite from scratch?
author Patrice Mandin <patmandin@gmail.com>
date Fri, 22 Sep 2006 21:52:20 +0000
parents c848c18684ab
children adf732f1f016
comparison
equal deleted inserted replaced
2035:c848c18684ab 2036:12ef90a41631
61 #define DEBUG_PRINT(what) 61 #define DEBUG_PRINT(what)
62 #undef DEBUG_VIDEO_XBIOS 62 #undef DEBUG_VIDEO_XBIOS
63 #endif 63 #endif
64 64
65 /* Initialization/Query functions */ 65 /* Initialization/Query functions */
66 static int XBIOS_VideoInit(_THIS, SDL_PixelFormat * vformat); 66 static int XBIOS_VideoInit(_THIS);
67 static void XBIOS_VideoQuit(_THIS);
68
69 #if 0
67 static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat * format, 70 static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat * format,
68 Uint32 flags); 71 Uint32 flags);
69 static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface * current, 72 static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface * current,
70 int width, int height, int bpp, 73 int width, int height, int bpp,
71 Uint32 flags); 74 Uint32 flags);
72 static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, 75 static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors,
73 SDL_Color * colors); 76 SDL_Color * colors);
74 static void XBIOS_VideoQuit(_THIS);
75 77
76 /* Hardware surface functions */ 78 /* Hardware surface functions */
77 static int XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface); 79 static int XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface);
78 static int XBIOS_LockHWSurface(_THIS, SDL_Surface * surface); 80 static int XBIOS_LockHWSurface(_THIS, SDL_Surface * surface);
79 static int XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface); 81 static int XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface);
88 90
89 /* To setup palette */ 91 /* To setup palette */
90 92
91 static unsigned short TT_palette[256]; 93 static unsigned short TT_palette[256];
92 static unsigned long F30_palette[256]; 94 static unsigned long F30_palette[256];
95 #endif
93 96
94 /* Xbios driver bootstrap functions */ 97 /* Xbios driver bootstrap functions */
95 98
96 static int 99 static int
97 XBIOS_Available(void) 100 XBIOS_Available(void)
148 { 151 {
149 SDL_VideoDevice *device; 152 SDL_VideoDevice *device;
150 SDL_VideoData *data; 153 SDL_VideoData *data;
151 154
152 /* Initialize all variables that we clean on shutdown */ 155 /* Initialize all variables that we clean on shutdown */
153 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); 156 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
154 if (device) { 157 if (device) {
155 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); 158 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
156 } 159 }
157 if (!device || !data) { 160 if (!device || !data) {
158 SDL_OutOfMemory(); 161 SDL_OutOfMemory();
164 device->driverdata = data; 167 device->driverdata = data;
165 168
166 /* Video functions */ 169 /* Video functions */
167 device->VideoInit = XBIOS_VideoInit; 170 device->VideoInit = XBIOS_VideoInit;
168 device->VideoQuit = XBIOS_VideoQuit; 171 device->VideoQuit = XBIOS_VideoQuit;
169 device->ListModes = XBIOS_ListModes; 172
170 device->SetVideoMode = XBIOS_SetVideoMode; 173 /* Modes */
171 device->SetColors = XBIOS_SetColors; 174 device->GetDisplayModes = NULL /*XBIOS_GetDisplayModes*/;
172 device->UpdateRects = NULL; 175 device->SetDisplayMode = NULL /*XBIOS_SetDisplayMode*/;
173 device->AllocHWSurface = XBIOS_AllocHWSurface; 176
174 device->LockHWSurface = XBIOS_LockHWSurface; 177 /* Events */
175 device->UnlockHWSurface = XBIOS_UnlockHWSurface; 178 device->PumpEvents = SDL_Atari_PumpEvents;
176 device->FlipHWSurface = XBIOS_FlipHWSurface;
177 device->FreeHWSurface = XBIOS_FreeHWSurface;
178 179
179 #if SDL_VIDEO_OPENGL 180 #if SDL_VIDEO_OPENGL
180 /* OpenGL functions */ 181 /* OpenGL functions */
181 device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary; 182 device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
182 device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress; 183 device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
183 device->GL_GetAttribute = SDL_AtariGL_GetAttribute; 184 device->GL_CreateContext = NULL;
184 device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent; 185 device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
185 device->GL_SwapBuffers = XBIOS_GL_SwapBuffers; 186 device->GL_SetSwapInterval = NULL;
186 #endif 187 device->GL_GetSwapInterval = NULL;
187 188 device->GL_SwapWindow = XBIOS_GL_SwapBuffers;
188 /* Events */ 189 device->GL_DeleteContext = NULL;
189 device->PumpEvents = Atari_PumpEvents; 190 #endif
190 191
191 device->free = XBIOS_DeleteDevice; 192 device->free = XBIOS_DeleteDevice;
192 193
193 return device; 194 return device;
194 } 195 }
196 VideoBootStrap XBIOS_bootstrap = { 197 VideoBootStrap XBIOS_bootstrap = {
197 "xbios", "Atari Xbios driver", 198 "xbios", "Atari Xbios driver",
198 XBIOS_Available, XBIOS_CreateDevice 199 XBIOS_Available, XBIOS_CreateDevice
199 }; 200 };
200 201
202 #if 0
201 void 203 void
202 SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, 204 SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height,
203 Uint16 depth, SDL_bool flags) 205 Uint16 depth, SDL_bool flags)
204 { 206 {
205 int i, curpos; 207 int i, curpos;
250 XBIOS_modelist[curpos].width = width; 252 XBIOS_modelist[curpos].width = width;
251 XBIOS_modelist[curpos].height = height; 253 XBIOS_modelist[curpos].height = height;
252 XBIOS_modelist[curpos].depth = depth; 254 XBIOS_modelist[curpos].depth = depth;
253 XBIOS_modelist[curpos].doubleline = flags; 255 XBIOS_modelist[curpos].doubleline = flags;
254 } 256 }
257 #endif
255 258
256 static int 259 static int
257 XBIOS_VideoInit(_THIS, SDL_PixelFormat * vformat) 260 XBIOS_VideoInit(_THIS)
258 { 261 {
262 XBIOS_InitModes(_this);
263
264 #if 0
259 int i, j8, j16; 265 int i, j8, j16;
260 xbiosmode_t *current_mode; 266 xbiosmode_t *current_mode;
261 unsigned long cookie_blow, cookie_scpn, cookie_cnts; 267 unsigned long cookie_blow, cookie_scpn, cookie_cnts;
262 268
263 /* Initialize all variables that we clean on shutdown */ 269 /* Initialize all variables that we clean on shutdown */
478 484
479 #if SDL_VIDEO_OPENGL 485 #if SDL_VIDEO_OPENGL
480 SDL_AtariGL_InitPointers(this); 486 SDL_AtariGL_InitPointers(this);
481 #endif 487 #endif
482 488
483 /* We're done! */ 489 #endif
490
484 return (0); 491 return (0);
485 } 492 }
486 493
494 static void
495 XBIOS_VideoQuit(_THIS)
496 {
497 /* int i, j;*/
498
499 XBIOS_QuitModes(_this);
500 Atari_ShutdownEvents();
501
502 #if 0
503 /* Restore video mode and palette */
504 #ifndef DEBUG_VIDEO_XBIOS
505 switch (XBIOS_cvdo >> 16) {
506 case VDO_ST:
507 case VDO_STE:
508 Setscreen(-1, XBIOS_oldvbase, XBIOS_oldvmode);
509 if (XBIOS_oldnumcol) {
510 Setpalette(XBIOS_oldpalette);
511 }
512 break;
513 case VDO_TT:
514 Setscreen(-1, XBIOS_oldvbase, -1);
515 EsetShift(XBIOS_oldvmode);
516 if (XBIOS_oldnumcol) {
517 EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
518 }
519 break;
520 case VDO_F30:
521 Setscreen(-1, XBIOS_oldvbase, -1);
522 if (XBIOS_centscreen) {
523 SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode);
524 } else {
525 VsetMode(XBIOS_oldvmode);
526 }
527 if (XBIOS_oldnumcol) {
528 VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
529 }
530 break;
531 }
532 Vsync();
533 #endif
534
535
536 #if SDL_VIDEO_OPENGL
537 if (gl_active) {
538 SDL_AtariGL_Quit(this, SDL_TRUE);
539 }
540 #endif
541
542 if (XBIOS_oldpalette) {
543 SDL_free(XBIOS_oldpalette);
544 XBIOS_oldpalette = NULL;
545 }
546 XBIOS_FreeBuffers(this);
547
548 /* Free mode list */
549 for (j = 0; j < NUM_MODELISTS; j++) {
550 for (i = 0; i < SDL_NUMMODES; i++) {
551 if (SDL_modelist[j][i] != NULL) {
552 SDL_free(SDL_modelist[j][i]);
553 SDL_modelist[j][i] = NULL;
554 }
555 }
556 }
557
558 if (XBIOS_modelist) {
559 SDL_free(XBIOS_modelist);
560 XBIOS_nummodes = 0;
561 XBIOS_modelist = NULL;
562 }
563
564 this->screen->pixels = NULL;
565 #endif
566 }
567
568 #if 0
487 static SDL_Rect ** 569 static SDL_Rect **
488 XBIOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) 570 XBIOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
489 { 571 {
490 /* 8 bits -> list 0 */ 572 /* 8 bits -> list 0 */
491 /* 16 bits -> list 1 */ 573 /* 16 bits -> list 1 */
874 break; 956 break;
875 } 957 }
876 958
877 return (1); 959 return (1);
878 } 960 }
961 #endif
879 962
880 /* Note: If we are terminated, this could be called in the middle of 963 /* Note: If we are terminated, this could be called in the middle of
881 another SDL video routine -- notably UpdateRects. 964 another SDL video routine -- notably UpdateRects.
882 */ 965 */
883 static void 966
884 XBIOS_VideoQuit(_THIS) 967 #if 0
885 {
886 int i, j;
887
888 Atari_ShutdownEvents();
889
890 /* Restore video mode and palette */
891 #ifndef DEBUG_VIDEO_XBIOS
892 switch (XBIOS_cvdo >> 16) {
893 case VDO_ST:
894 case VDO_STE:
895 Setscreen(-1, XBIOS_oldvbase, XBIOS_oldvmode);
896 if (XBIOS_oldnumcol) {
897 Setpalette(XBIOS_oldpalette);
898 }
899 break;
900 case VDO_TT:
901 Setscreen(-1, XBIOS_oldvbase, -1);
902 EsetShift(XBIOS_oldvmode);
903 if (XBIOS_oldnumcol) {
904 EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
905 }
906 break;
907 case VDO_F30:
908 Setscreen(-1, XBIOS_oldvbase, -1);
909 if (XBIOS_centscreen) {
910 SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode);
911 } else {
912 VsetMode(XBIOS_oldvmode);
913 }
914 if (XBIOS_oldnumcol) {
915 VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
916 }
917 break;
918 }
919 Vsync();
920 #endif
921
922
923 #if SDL_VIDEO_OPENGL
924 if (gl_active) {
925 SDL_AtariGL_Quit(this, SDL_TRUE);
926 }
927 #endif
928
929 if (XBIOS_oldpalette) {
930 SDL_free(XBIOS_oldpalette);
931 XBIOS_oldpalette = NULL;
932 }
933 XBIOS_FreeBuffers(this);
934
935 /* Free mode list */
936 for (j = 0; j < NUM_MODELISTS; j++) {
937 for (i = 0; i < SDL_NUMMODES; i++) {
938 if (SDL_modelist[j][i] != NULL) {
939 SDL_free(SDL_modelist[j][i]);
940 SDL_modelist[j][i] = NULL;
941 }
942 }
943 }
944
945 if (XBIOS_modelist) {
946 SDL_free(XBIOS_modelist);
947 XBIOS_nummodes = 0;
948 XBIOS_modelist = NULL;
949 }
950
951 this->screen->pixels = NULL;
952 }
953
954 #if SDL_VIDEO_OPENGL 968 #if SDL_VIDEO_OPENGL
955 969
956 static void 970 static void
957 XBIOS_GL_SwapBuffers(_THIS) 971 XBIOS_GL_SwapBuffers(_THIS)
958 { 972 {
960 XBIOS_FlipHWSurface(this, this->screen); 974 XBIOS_FlipHWSurface(this, this->screen);
961 SDL_AtariGL_MakeCurrent(this); 975 SDL_AtariGL_MakeCurrent(this);
962 } 976 }
963 977
964 #endif 978 #endif
979 #endif
965 /* vi: set ts=4 sw=4 expandtab: */ 980 /* vi: set ts=4 sw=4 expandtab: */