Mercurial > sdl-ios-xcode
comparison src/video/gapi/SDL_gapivideo.c @ 1465:8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Converted the disk audio driver to SDL_RWops for portability
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 04 Mar 2006 08:24:35 +0000 |
parents | d910939febfa |
children | 4aac8563c296 |
comparison
equal
deleted
inserted
replaced
1464:af30090c0330 | 1465:8dfa9a6d69a5 |
---|---|
31 // TODO: test on be300 and HPC ( check WinDib fullscreen keys catching ) | 31 // TODO: test on be300 and HPC ( check WinDib fullscreen keys catching ) |
32 // TODO: test on smartphones | 32 // TODO: test on smartphones |
33 // TODO: windib on SH3 PPC2000 landscape test | 33 // TODO: windib on SH3 PPC2000 landscape test |
34 // TODO: optimize 8bpp landscape mode | 34 // TODO: optimize 8bpp landscape mode |
35 | 35 |
36 // there is some problems in runnings apps from a device landscape mode | |
37 // due to WinCE bugs. Some works and some - does not. | |
38 // TODO: finish Axim Dell X30 and user landscape mode, device landscape mode | |
39 // TODO: finish Axim Dell X30 user portrait, device landscape stylus conversion | |
40 // TODO: fix running GAPI apps from landscape mode - | |
41 // wince goes to portrait mode, but does not update video memory | |
42 | |
43 | |
44 #include "SDL.h" | |
45 #include "SDL_error.h" | |
36 #include "SDL_video.h" | 46 #include "SDL_video.h" |
37 #include "SDL_mouse.h" | 47 #include "SDL_mouse.h" |
38 #include "../SDL_sysvideo.h" | 48 #include "../SDL_sysvideo.h" |
39 #include "../SDL_pixels_c.h" | 49 #include "../SDL_pixels_c.h" |
40 #include "../../events/SDL_events_c.h" | 50 #include "../../events/SDL_events_c.h" |
41 | 51 #include "../wincommon/SDL_syswm_c.h" |
42 #include "SDL_syswm_c.h" | 52 #include "../wincommon/SDL_sysmouse_c.h" |
43 #include "SDL_sysmouse_c.h" | 53 #include "../windib/SDL_dibevents_c.h" |
44 #include "SDL_dibevents_c.h" | |
45 | 54 |
46 #include "SDL_gapivideo.h" | 55 #include "SDL_gapivideo.h" |
47 | 56 |
48 #define GAPIVID_DRIVER_NAME "gapi" | 57 #define GAPIVID_DRIVER_NAME "gapi" |
49 | 58 |
53 #define REPORT_VIDEO_INFO 0 | 62 #define REPORT_VIDEO_INFO 0 |
54 #endif | 63 #endif |
55 | 64 |
56 // for testing with GapiEmu | 65 // for testing with GapiEmu |
57 #define USE_GAPI_EMU 0 | 66 #define USE_GAPI_EMU 0 |
67 #define EMULATE_AXIM_X30 0 | |
68 #define WITHOUT_GAPI 0 | |
58 | 69 |
59 #if USE_GAPI_EMU && !REPORT_VIDEO_INFO | 70 #if USE_GAPI_EMU && !REPORT_VIDEO_INFO |
60 #pragma message("Warning: Using GapiEmu in release build. I assume you'd like to set USE_GAPI_EMU to zero.") | 71 #pragma message("Warning: Using GapiEmu in release build. I assume you'd like to set USE_GAPI_EMU to zero.") |
61 #endif | 72 #endif |
62 | 73 |
111 | 122 |
112 #define GETRAWFRAMEBUFFER 0x00020001 | 123 #define GETRAWFRAMEBUFFER 0x00020001 |
113 | 124 |
114 #define FORMAT_565 1 | 125 #define FORMAT_565 1 |
115 #define FORMAT_555 2 | 126 #define FORMAT_555 2 |
116 #define FORMAT_OTHER 3 | 127 #define FORMAT_OTHER 3 |
128 | |
129 /* Dell Axim x30 hangs when we use GAPI from landscape, | |
130 so lets avoid using GxOpenDisplay there via GETGXINFO trick | |
131 It seems that GAPI subsystem use the same ExtEscape code. | |
132 */ | |
133 #define GETGXINFO 0x00020000 | |
134 | |
135 typedef struct GXDeviceInfo | |
136 { | |
137 long Version; //00 (should filled with 100 before calling ExtEscape) | |
138 void * pvFrameBuffer; //04 | |
139 unsigned long cbStride; //08 | |
140 unsigned long cxWidth; //0c | |
141 unsigned long cyHeight; //10 | |
142 unsigned long cBPP; //14 | |
143 unsigned long ffFormat; //18 | |
144 char Unused[0x84-7*4]; | |
145 } GXDeviceInfo; | |
117 | 146 |
118 static int GAPI_Available(void) | 147 static int GAPI_Available(void) |
119 { | 148 { |
120 // try to use VGA display, even on emulator | 149 // try to use VGA display, even on emulator |
121 HDC hdc = GetDC(NULL); | 150 HDC hdc = GetDC(NULL); |
122 int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *)&g_RawFrameBufferInfo); | 151 int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *)&g_RawFrameBufferInfo); |
123 ReleaseDC(NULL, hdc); | 152 ReleaseDC(NULL, hdc); |
124 g_bRawBufferAvailable = result > 0; | 153 g_bRawBufferAvailable = result > 0; |
154 | |
155 #if WITHOUT_GAPI | |
156 return g_bRawBufferAvailable; | |
157 #endif | |
125 | 158 |
126 #if USE_GAPI_EMU | 159 #if USE_GAPI_EMU |
127 g_hGapiLib = LoadLibrary(_T("GAPI_Emu.dll")); | 160 g_hGapiLib = LoadLibrary(_T("GAPI_Emu.dll")); |
128 if( !g_hGapiLib ) | 161 if( !g_hGapiLib ) |
129 { | 162 { |
330 { | 363 { |
331 this->hidden->gxProperties = this->hidden->gxFunc.GXGetDisplayProperties(); | 364 this->hidden->gxProperties = this->hidden->gxFunc.GXGetDisplayProperties(); |
332 this->hidden->needUpdate = 1; | 365 this->hidden->needUpdate = 1; |
333 this->hidden->hiresFix = 0; | 366 this->hidden->hiresFix = 0; |
334 this->hidden->useVga = 0; | 367 this->hidden->useVga = 0; |
368 this->hidden->useGXOpenDisplay = 1; | |
369 | |
335 #ifdef _ARM_ | 370 #ifdef _ARM_ |
336 /* check some devices and extract addition info */ | 371 /* check some devices and extract addition info */ |
337 SystemParametersInfo( SPI_GETOEMINFO, sizeof( oemstr ), oemstr, 0 ); | 372 SystemParametersInfo( SPI_GETOEMINFO, sizeof( oemstr ), oemstr, 0 ); |
338 | 373 |
339 // buggy iPaq38xx | 374 // buggy iPaq38xx |
341 { | 376 { |
342 this->hidden->videoMem = (PIXEL*)0xac0755a0; | 377 this->hidden->videoMem = (PIXEL*)0xac0755a0; |
343 this->hidden->gxProperties.cbxPitch = -640; | 378 this->hidden->gxProperties.cbxPitch = -640; |
344 this->hidden->gxProperties.cbyPitch = 2; | 379 this->hidden->gxProperties.cbyPitch = 2; |
345 this->hidden->needUpdate = 0; | 380 this->hidden->needUpdate = 0; |
381 } | |
382 #if (EMULATE_AXIM_X30 == 0) | |
383 // buggy Dell Axim X30 | |
384 if( _tcsncmp(oemstr, L"Dell Axim X30", 13) == 0 ) | |
385 #endif | |
386 { | |
387 GXDeviceInfo gxInfo = {0}; | |
388 HDC hdc = GetDC(NULL); | |
389 int result; | |
390 | |
391 gxInfo.Version = 100; | |
392 result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *)&gxInfo); | |
393 if( result > 0 ) | |
394 { | |
395 this->hidden->useGXOpenDisplay = 0; | |
396 this->hidden->videoMem = gxInfo.pvFrameBuffer; | |
397 this->hidden->needUpdate = 0; | |
398 this->hidden->gxProperties.cbxPitch = 2; | |
399 this->hidden->gxProperties.cbyPitch = 480; | |
400 this->hidden->gxProperties.cxWidth = gxInfo.cxWidth; | |
401 this->hidden->gxProperties.cyHeight = gxInfo.cyHeight; | |
402 this->hidden->gxProperties.ffFormat = gxInfo.ffFormat; | |
403 } | |
346 } | 404 } |
347 #endif | 405 #endif |
348 } else | 406 } else |
349 { | 407 { |
350 this->hidden->needUpdate = 0; | 408 this->hidden->needUpdate = 0; |
596 if ( !this->hidden->needUpdate && !this->hidden->videoMem) { | 654 if ( !this->hidden->needUpdate && !this->hidden->videoMem) { |
597 SDL_SetError("Couldn't get address of video memory, may be unsupported device or bug"); | 655 SDL_SetError("Couldn't get address of video memory, may be unsupported device or bug"); |
598 return(NULL); | 656 return(NULL); |
599 } | 657 } |
600 | 658 |
601 /* detect landscape mode */ | 659 /* detect user landscape mode */ |
602 if( (width > height) && (GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN))) | 660 if( (width > height) && (GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN))) |
603 gapi->userOrientation = SDL_ORIENTATION_RIGHT; | 661 gapi->userOrientation = SDL_ORIENTATION_RIGHT; |
604 | 662 |
605 /* shall we apply hires fix? for example when we do not use hires resource */ | 663 /* shall we apply hires fix? for example when we do not use hires resource */ |
606 gapi->hiresFix = 0; | 664 gapi->hiresFix = 0; |
608 { | 666 { |
609 if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height > GetSystemMetrics(SM_CXSCREEN))) | 667 if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height > GetSystemMetrics(SM_CXSCREEN))) |
610 gapi->hiresFix = 1; | 668 gapi->hiresFix = 1; |
611 } else | 669 } else |
612 if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN))) | 670 if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN))) |
613 gapi->hiresFix = 1; | 671 if( !((width == GetSystemMetrics(SM_CYSCREEN)) && (height == GetSystemMetrics(SM_CXSCREEN)))) // user portrait, device landscape |
672 gapi->hiresFix = 1; | |
614 | 673 |
615 switch( gapi->userOrientation ) | 674 switch( gapi->userOrientation ) |
616 { | 675 { |
617 case SDL_ORIENTATION_UP: | 676 case SDL_ORIENTATION_UP: |
618 gapi->startOffset = 0; | 677 gapi->startOffset = 0; |
650 /* GAPI is always fullscreen, title bar is useless */ | 709 /* GAPI is always fullscreen, title bar is useless */ |
651 style = 0; | 710 style = 0; |
652 | 711 |
653 if (!SDL_windowid) | 712 if (!SDL_windowid) |
654 SetWindowLong(SDL_Window, GWL_STYLE, style); | 713 SetWindowLong(SDL_Window, GWL_STYLE, style); |
655 | 714 |
656 /* Allocate bitmap */ | 715 /* Allocate bitmap */ |
657 if(gapiBuffer) | 716 if(gapiBuffer) |
658 { | 717 { |
659 SDL_free(gapiBuffer); | 718 SDL_free(gapiBuffer); |
660 gapiBuffer = NULL; | 719 gapiBuffer = NULL; |
669 | 728 |
670 SDL_memset(gapiBuffer, 255, video->h * video->pitch); | 729 SDL_memset(gapiBuffer, 255, video->h * video->pitch); |
671 MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE); | 730 MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE); |
672 ShowWindow(SDL_Window, SW_SHOW); | 731 ShowWindow(SDL_Window, SW_SHOW); |
673 SetForegroundWindow(SDL_Window); | 732 SetForegroundWindow(SDL_Window); |
733 | |
734 /* Open GAPI display */ | |
735 if( !gapi->useVga && this->hidden->useGXOpenDisplay ) | |
736 if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) ) | |
737 { | |
738 SDL_SetError("Couldn't initialize GAPI"); | |
739 return(NULL); | |
740 } | |
674 | 741 |
675 #if REPORT_VIDEO_INFO | 742 #if REPORT_VIDEO_INFO |
676 printf("Video properties:\n"); | 743 printf("Video properties:\n"); |
677 printf("display bpp: %d\n", gapi->gxProperties.cBPP); | 744 printf("display bpp: %d\n", gapi->gxProperties.cBPP); |
678 printf("display width: %d\n", gapi->gxProperties.cxWidth); | 745 printf("display width: %d\n", gapi->gxProperties.cxWidth); |
679 printf("display height: %d\n", gapi->gxProperties.cyHeight); | 746 printf("display height: %d\n", gapi->gxProperties.cyHeight); |
680 printf("x pitch: %d\n", gapi->gxProperties.cbxPitch); | 747 printf("x pitch: %d\n", gapi->gxProperties.cbxPitch); |
681 printf("y pitch: %d\n", gapi->gxProperties.cbyPitch); | 748 printf("y pitch: %d\n", gapi->gxProperties.cbyPitch); |
682 printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); | 749 printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); |
750 | |
751 if( !gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate) | |
752 { | |
753 gapi->videoMem = gapi->gxFunc.GXBeginDraw(); | |
754 gapi->gxFunc.GXEndDraw(); | |
755 } | |
756 | |
683 printf("video memory: 0x%x\n", gapi->videoMem); | 757 printf("video memory: 0x%x\n", gapi->videoMem); |
684 printf("need update: %d\n", gapi->needUpdate); | 758 printf("need update: %d\n", gapi->needUpdate); |
685 printf("hi-res fix: %d\n", gapi->hiresFix); | 759 printf("hi-res fix: %d\n", gapi->hiresFix); |
686 printf("VGA is available on the device: %d\n", g_bRawBufferAvailable); | 760 printf("VGA is available on the device: %d\n", g_bRawBufferAvailable); |
687 printf("use VGA resolution: %d\n", gapi->useVga); | 761 printf("use raw framebuffer: %d\n", gapi->useVga); |
688 printf("video surface bpp: %d\n", video->format->BitsPerPixel); | 762 printf("video surface bpp: %d\n", video->format->BitsPerPixel); |
689 printf("video surface width: %d\n", video->w); | 763 printf("video surface width: %d\n", video->w); |
690 printf("video surface height: %d\n", video->h); | 764 printf("video surface height: %d\n", video->h); |
691 #endif | 765 #endif |
692 | 766 |
693 /* Open GAPI display */ | 767 |
694 if( !gapi->useVga ) | |
695 if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) ) | |
696 { | |
697 SDL_SetError("Couldn't initialize GAPI"); | |
698 return(NULL); | |
699 } | |
700 | |
701 /* Blank screen */ | 768 /* Blank screen */ |
702 allScreen.x = allScreen.y = 0; | 769 allScreen.x = allScreen.y = 0; |
703 allScreen.w = video->w - 1; | 770 allScreen.w = video->w - 1; |
704 allScreen.h = video->h - 1; | 771 allScreen.h = video->h - 1; |
705 GAPI_UpdateRects(this, 1, &allScreen); | 772 GAPI_UpdateRects(this, 1, &allScreen); |
788 destPointer += step; | 855 destPointer += step; |
789 } | 856 } |
790 else | 857 else |
791 { | 858 { |
792 destPointer += gapi->gxProperties.cbyPitch / 2; | 859 destPointer += gapi->gxProperties.cbyPitch / 2; |
860 | |
793 while(width--) // iPaq 3660 | 861 while(width--) // iPaq 3660 |
794 { | 862 { |
795 *(DWORD*)destPointer =(*line1++ << 16) | *line2++; | 863 *(DWORD*)destPointer =(*line1++ << 16) | *line2++; |
796 destPointer += step; | 864 destPointer += step; |
797 } | 865 } |