Commit 3783e84c authored by CeRiAl's avatar CeRiAl

Applied patch libsdl_20090809_diff from http://users.uoa.gr/~knakos/scummvm/libraries/

parent 1f51aedc
CC = arm-wince-mingw32ce-gcc
AS = arm-wince-mingw32ce-as
AR = arm-wince-mingw32ce-ar cru
RANLIB = arm-wince-mingw32ce-ranlib
CFLAGS = -Iinclude -Isrc/audio -Isrc/cdrom -Isrc/timer -Isrc/joystick -Isrc/events -Isrc/video -Isrc/thread -Isrc/thread/win32 -Isrc -Isrc/video/wincommon -Isrc/video/windib -UWM_GETMINMAXINFO -UWS_MAXIMIZE
CFLAGS += -D_WIN32_WCE=300 -D_ARM_ -D__ARM__ -DUNICODE -D_UNICODE -DNO_SIGNAL_H -DENABLE_WINDIB -DENABLE_WINGAPI -D_FORCE_CE_SEMAPHORE -DWIN32 -DGCC_BUILD -D__stdcall__= -DNO_STDIO_REDIRECT
CFLAGS += -DWINCE_EXTRADEBUG
#CFLAGS += -DWMMSG_DEBUG
#CFLAGS += -DDEBUG -g
CFLAGS += -O3 -march=armv4 -mtune=xscale
OBJS = src/audio/SDL_audio.o src/audio/SDL_audiocvt.o src/audio/SDL_audiodev.o src/audio/SDL_audiomem.o src/audio/SDL_mixer.o src/audio/SDL_wave.o
OBJS += src/audio/windib/SDL_dibaudio.o
OBJS += src/cdrom/SDL_cdrom.o src/cdrom/win32/SDL_syscdrom.o src/endian/SDL_endian.o src/events/SDL_active.o src/events/SDL_events.o src/events/SDL_expose.o
OBJS += src/events/SDL_keyboard.o src/events/SDL_mouse.o src/events/SDL_quit.o src/events/SDL_resize.o src/file/SDL_rwops.o src/joystick/SDL_joystick.o
OBJS += src/joystick/win32/SDL_mmjoystick.o src/thread/win32/SDL_sysmutex.o src/thread/win32/SDL_syssem.o src/thread/win32/SDL_systhread.o
OBJS += src/thread/SDL_thread.o src/thread/win32/win_ce_semaphore.o src/timer/win32/SDL_systimer.o src/timer/SDL_timer.o src/video/windib/SDL_dibevents.o
OBJS += src/video/windib/SDL_dibvideo.o src/video/wincommon/SDL_sysevents.o src/video/wincommon/SDL_sysmouse.o src/video/wincommon/SDL_syswm.o
OBJS += src/video/wingapi/SDL_gapivideo.o src/video/wingapi/ARM_rot.o src/video/SDL_blit.o src/video/SDL_blit_0.o src/video/SDL_blit_1.o src/video/SDL_blit_A.o
OBJS += src/video/ARM_blit1to2.o src/video/SDL_blit_N.o src/video/SDL_bmp.o src/video/SDL_cursor.o src/video/SDL_gamma.o src/video/SDL_pixels.o src/video/SDL_RLEaccel.o
OBJS += src/video/SDL_stretch.o src/video/SDL_surface.o src/video/SDL_video.o src/video/SDL_yuv.o src/video/SDL_yuv_mmx.o src/video/SDL_yuv_sw.o
OBJS += src/main/win32/SDL_main.o src/SDL.o src/SDL_error.o src/SDL_fatal.o src/SDL_getenv.o src/SDL_loadso.o
all : libSDL.lib
#ARM_blit1to2.o :
# arm-wince-pe-as $*.s -o $@
libSDL.lib : $(OBJS)
$(AR) $@ $^
$(RANLIB) $@
clean :
rm `find . -name *.o`
......@@ -53,6 +53,7 @@ typedef struct SDL_AudioSpec {
Uint16 samples; /* Audio buffer size in samples (power of 2) */
Uint16 padding; /* Necessary for some compile environments */
Uint32 size; /* Audio buffer size in bytes (calculated) */
Uint8 thread_priority; /* Thread priority */
/* This function is called when the audio device needs more data.
'stream' is a pointer to the audio data buffer
'len' is the length of that buffer in bytes.
......
......@@ -258,7 +258,52 @@ typedef enum {
SDLK_F13 = 294,
SDLK_F14 = 295,
SDLK_F15 = 296,
#ifdef _WIN32_WCE
SDLK_F16 = 297,
SDLK_F17 = 298,
SDLK_F18 = 299,
SDLK_F19 = 300,
SDLK_F20 = 301,
SDLK_F21 = 302,
SDLK_F22 = 303,
SDLK_F23 = 304,
SDLK_F24 = 305,
/* Key state modifier keys */
SDLK_NUMLOCK = 310,
SDLK_CAPSLOCK = 311,
SDLK_SCROLLOCK = 312,
SDLK_RSHIFT = 313,
SDLK_LSHIFT = 314,
SDLK_RCTRL = 315,
SDLK_LCTRL = 316,
SDLK_RALT = 317,
SDLK_LALT = 318,
SDLK_RMETA = 319,
SDLK_LMETA = 320,
SDLK_LSUPER = 321, /* Left "Windows" key */
SDLK_RSUPER = 322, /* Right "Windows" key */
SDLK_MODE = 323, /* "Alt Gr" key */
SDLK_COMPOSE = 324, /* Multi-key compose key */
/* Miscellaneous function keys */
SDLK_HELP = 325,
SDLK_PRINT = 326,
SDLK_SYSREQ = 327,
SDLK_BREAK = 328,
SDLK_MENU = 329,
SDLK_POWER = 330, /* Power Macintosh power key */
SDLK_EURO = 331, /* Some european keyboards */
SDLK_UNDO = 332, /* Atari keyboard has Undo */
/* Add any other keys here */
SDLK_APP1 = 340,
SDLK_APP2 = 341,
SDLK_APP3 = 342,
SDLK_APP4 = 343,
SDLK_APP5 = 344,
SDLK_APP6 = 345,
#else
/* Key state modifier keys */
SDLK_NUMLOCK = 300,
SDLK_CAPSLOCK = 301,
......@@ -285,8 +330,7 @@ typedef enum {
SDLK_POWER = 320, /* Power Macintosh power key */
SDLK_EURO = 321, /* Some european keyboards */
SDLK_UNDO = 322, /* Atari keyboard has Undo */
/* Add any other keys here */
#endif
SDLK_LAST
} SDLKey;
......
......@@ -146,6 +146,9 @@ typedef struct SDL_Surface {
#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */
#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */
#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
#define SDL_PORTRTVIDEO 0x00100000 /* wince */
#define SDL_LANDSCVIDEO 0x00200000 /* wince */
#define SDL_INVLNDVIDEO 0x00400000 /* wince */
/* Evaluates to true if the surface needs to be locked before access */
#define SDL_MUSTLOCK(surface) \
......
......@@ -458,7 +458,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
}
/* Allocate a fake audio memory buffer */
audio->fake_stream = SDL_AllocAudioMem(audio->spec.size);
audio->fake_stream = (Uint8 *) SDL_AllocAudioMem(audio->spec.size);
if ( audio->fake_stream == NULL ) {
SDL_CloseAudio();
SDL_OutOfMemory();
......
......@@ -40,6 +40,7 @@ static char rcsid =
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
#include "win_ce_semaphore.h"
#endif
#undef waveOutGetErrorText
/* Audio driver functions */
......@@ -147,7 +148,7 @@ static void SetMMerror(char *function, MMRESULT code)
/* Set high priority for the audio thread */
static void DIB_ThreadInit(_THIS)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
SetThreadPriority(GetCurrentThread(), this->hidden->thread_priority);
}
void DIB_WaitAudio(_THIS)
......@@ -229,6 +230,10 @@ int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec)
int i;
WAVEFORMATEX waveformat;
this->hidden->thread_priority = spec->thread_priority;
if (this->hidden->thread_priority <= 0)
this->hidden->thread_priority = THREAD_PRIORITY_NORMAL;
/* Initialize the wavebuf structures for closing */
sound = NULL;
audio_sem = NULL;
......
......@@ -41,6 +41,7 @@ struct SDL_PrivateAudioData {
Uint8 *mixbuf; /* The raw allocated mixing buffer */
WAVEHDR wavebuf[NUM_BUFFERS]; /* Wave audio fragments */
int next_buffer;
Uint8 thread_priority; /* Thread priority */
};
/* Old variable names */
......
......@@ -30,12 +30,30 @@ static char rcsid =
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#ifndef _WIN32_WCE
#include <mmsystem.h>
#endif
#include "SDL_error.h"
#include "SDL_cdrom.h"
#ifdef _WIN32_WCE
int SDL_SYS_CDInit() {
return 0;
}
static void SDL_SYS_CDClose(SDL_CD *cdrom) {
}
void SDL_SYS_CDQuit(void) {
}
#else
#include "SDL_syscdrom.h"
/* This really broken?? */
#define BROKEN_MCI_PAUSE /* Pausing actually stops play -- Doh! */
......@@ -387,3 +405,5 @@ void SDL_SYS_CDQuit(void)
SDL_numcds = 0;
}
}
#endif
......@@ -318,6 +318,37 @@ int SDL_KeyboardInit(void)
keynames[SDLK_EURO] = "euro";
keynames[SDLK_UNDO] = "undo";
#ifdef _WIN32_WCE
/* Name the CE keys with their special names */
keynames[SDLK_F1] = "softkey A";
keynames[SDLK_F2] = "softkey B";
keynames[SDLK_F3] = "talk/call";
keynames[SDLK_F4] = "end call";
keynames[SDLK_F6] = "volume up";
keynames[SDLK_F7] = "volume down";
keynames[SDLK_F8] = "star";
keynames[SDLK_F9] = "pound";
keynames[SDLK_F10] = "record";
keynames[SDLK_F11] = "symbol";
keynames[SDLK_F16] = "speaker";
keynames[SDLK_F17] = "flip";
keynames[SDLK_F18] = "power";
keynames[SDLK_F19] = "red key";
keynames[SDLK_F20] = "rocker";
keynames[SDLK_F21] = "dpad";
keynames[SDLK_F22] = "f22";
keynames[SDLK_F23] = "rocker action";
keynames[SDLK_F24] = "f24";
keynames[SDLK_APP1] = "application 1";
keynames[SDLK_APP2] = "application 2";
keynames[SDLK_APP3] = "application 3";
keynames[SDLK_APP4] = "application 4";
keynames[SDLK_APP5] = "application 5";
keynames[SDLK_APP6] = "application 6";
keynames[SDLK_LSUPER] = "home";
keynames[SDLK_ESCAPE] = "back";
keynames[SDLK_RETURN] = "action";
#endif
/* Done. Whew. */
return(0);
}
......
......@@ -36,6 +36,39 @@ static char rcsid =
#include "SDL_joystick_c.h"
#include <windows.h>
#ifdef _WIN32_WCE
int SDL_SYS_JoystickInit(void)
{
return 0;
}
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{
}
const char *SDL_SYS_JoystickName(int index)
{
return NULL;
}
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
{
return 0;
}
void SDL_SYS_JoystickQuit(void)
{
return;
}
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{
}
#else
#include <mmsystem.h>
#include <regstr.h>
......@@ -421,3 +454,5 @@ void SetMMerror(char *function, int code)
}
SDL_SetError("%s", errbuf);
}
#endif
......@@ -13,47 +13,34 @@
#include <malloc.h> /* For _alloca() */
#ifdef _WIN32_WCE
# define DIR_SEPERATOR TEXT("\\")
# undef _getcwd
# define _getcwd(str,len) wcscpy(str,TEXT(""))
# define setbuf(f,b)
# define setvbuf(w,x,y,z)
# define fopen _wfopen
# define freopen _wfreopen
# define remove(x) DeleteFile(x)
# define strcat wcscat
#else
# define DIR_SEPERATOR TEXT("/")
# include <direct.h>
#endif
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
#ifdef main
# ifndef _WIN32_WCE_EMULATION
# undef main
# endif /* _WIN32_WCE_EMULATION */
#endif /* main */
TCHAR fileUnc[MAX_PATH+1];
static TCHAR *_getcwd(TCHAR *buffer, int maxlen)
{
TCHAR *plast;
/* The standard output files */
#define STDOUT_FILE TEXT("stdout.txt")
#define STDERR_FILE TEXT("stderr.txt")
GetModuleFileName(NULL, fileUnc, MAX_PATH);
plast = wcsrchr(fileUnc, TEXT('\\'));
if(plast) *plast = 0;
/* Special trick to keep start menu clean... */
if(_wcsicmp(fileUnc, TEXT("\\windows\\start menu")) == 0)
wcscpy(fileUnc, TEXT("\\Apps"));
#ifndef NO_STDIO_REDIRECT
# ifdef _WIN32_WCE
static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];
# else
static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];
# endif
#endif
if(buffer) wcsncpy(buffer, fileUnc, maxlen);
return fileUnc;
}
#if defined(_WIN32_WCE) && _WIN32_WCE < 300
# if defined(_WIN32_WCE) && _WIN32_WCE < 300
/* seems to be undefined in Win CE although in online help */
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
# define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
/* seems to be undefined in Win CE although in online help */
char *strrchr(char *str, int c)
......@@ -75,7 +62,38 @@ char *strrchr(char *str, int c)
}
return p;
}
#endif /* _WIN32_WCE < 300 */
# endif /* _WIN32_WCE < 300 */
#else
# define DIR_SEPERATOR TEXT("/")
# include <direct.h>
#endif
/* The standard output files */
# define STDOUT_FILE TEXT("stdout.txt")
# define STDERR_FILE TEXT("stderr.txt")
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
#ifdef main
# ifndef _WIN32_WCE_EMULATION
# undef main
# endif /* _WIN32_WCE_EMULATION */
#endif /* main */
#ifndef NO_STDIO_REDIRECT
# ifndef _WIN32_WCE
static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];
# else
static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];
# endif
#endif
/* Parse a command line buffer into arguments */
static int ParseCommandLine(char *cmdline, char **argv)
......@@ -160,7 +178,7 @@ static void __cdecl cleanup_output(void)
#ifndef NO_STDIO_REDIRECT
/* See if the files have any output in them */
if ( stdoutPath[0] ) {
file = fopen(stdoutPath, TEXT("rb"));
file = (FILE *) fopen(stdoutPath, TEXT("rb"));
if ( file ) {
empty = (fgetc(file) == EOF) ? 1 : 0;
fclose(file);
......@@ -170,7 +188,7 @@ static void __cdecl cleanup_output(void)
}
}
if ( stderrPath[0] ) {
file = fopen(stderrPath, TEXT("rb"));
file = (FILE *) fopen(stderrPath, TEXT("rb"));
if ( file ) {
empty = (fgetc(file) == EOF) ? 1 : 0;
fclose(file);
......@@ -220,8 +238,11 @@ int console_main(int argc, char *argv[])
ShowError("WinMain() error", SDL_GetError());
return(FALSE);
}
#if defined(_WIN32_WCE) && (!defined(GCC_BUILD) && !defined(__GNUC__))
atexit(cleanup_output);
atexit(SDL_Quit);
#endif
#ifndef DISABLE_VIDEO
#if 0
......@@ -249,6 +270,10 @@ int console_main(int argc, char *argv[])
SDL_main(argc, argv);
/* Exit cleanly, calling atexit() functions */
#if defined(_WIN32_WCE) && defined(__GNUC__)
cleanup_output();
SDL_Quit();
#endif
exit(0);
/* Hush little compiler, don't you cry... */
......@@ -290,49 +315,49 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
/* Redirect standard input and standard output */
newfp = freopen(stdoutPath, TEXT("w"), stdout);
newfp = (FILE *) freopen(stdoutPath, TEXT("w"), stdout);
#ifndef _WIN32_WCE
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stdout)
stdout = fopen(stdoutPath, TEXT("w"));
#else
newfp = fopen(stdoutPath, TEXT("w"));
newfp = (FILE *) fopen(stdoutPath, TEXT("w"));
if ( newfp ) {
*stdout = *newfp;
}
#endif
}
#endif /* _WIN32_WCE */
_getcwd( stderrPath, sizeof( stderrPath ) );
strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
newfp = freopen(stderrPath, TEXT("w"), stderr);
#ifndef _WIN32_WCE
newfp = (FILE *) freopen(stderrPath, TEXT("w"), stderr);
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stderr)
stderr = fopen(stderrPath, TEXT("w"));
#else
newfp = fopen(stderrPath, TEXT("w"));
newfp = (FILE *) fopen(stderrPath, TEXT("w"));
if ( newfp ) {
*stderr = *newfp;
}
#endif
}
#endif /* _WIN32_WCE */
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */
setbuf(stderr, NULL); /* No buffering */
#endif /* !NO_STDIO_REDIRECT */
#ifdef _WIN32_WCE
if (wcsncmp(szCmdLine, TEXT("\\"), 1)) {
nLen = wcslen(szCmdLine)+128+1;
bufp = (wchar_t *)alloca(nLen*2);
wcscpy (bufp, TEXT("\""));
GetModuleFileName(NULL, bufp+1, 128-3);
wcscpy (bufp+wcslen(bufp), TEXT("\" "));
wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
} else
bufp = szCmdLine;
nLen = wcslen(bufp)+1;
cmdline = (char *)alloca(nLen);
if ( cmdline == NULL ) {
......@@ -357,6 +382,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
}
ParseCommandLine(cmdline, argv);
/* fix gdb/emulator combo */
while (argc > 1 && !strstr(argv[0], ".exe")) {
OutputDebugString(TEXT("SDL: gdb argv[0] fixup\n"));
*(argv[1]-1) = ' ';
int i;
for (i=1; i<argc; i++)
argv[i] = argv[i+1];
argc--;
}
/* Run the main program (after a little SDL initialization) */
return(console_main(argc, argv));
}
......@@ -59,17 +59,19 @@ SYNCHHANDLE CreateSemaphoreCE (
{
SYNCHHANDLE hSynch = NULL, result = NULL;
__try
// __try
{
if (lInitialCount > lMaximumCount || lMaximumCount < 0 || lInitialCount < 0)
{
/* Bad parameters */
SetLastError (SYNCH_ERROR);
__leave;
// __leave;
return CleanUp(hSynch, 6);
}
hSynch = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, SYNCH_HANDLE_SIZE);
if (hSynch == NULL) __leave;
// if (hSynch == NULL) __leave;
if (hSynch == NULL) return CleanUp(hSynch, 6);
hSynch->MaxCount = lMaximumCount;
hSynch->CurCount = lInitialCount;
......@@ -85,12 +87,12 @@ SYNCHHANDLE CreateSemaphoreCE (
ReleaseMutex (hSynch->hMutex);
hSynch->hSemph = NULL;
}
__finally
{
/* Return with the handle, or, if there was any error, return
a null after closing any open handles and freeing any allocated memory. */
// __finally
// {
// /* Return with the handle, or, if there was any error, return
// a null after closing any open handles and freeing any allocated memory. */
result=CleanUp(hSynch, 6 /* An event and a mutex, but no semaphore. */);
}
// }
return result;
}
......@@ -103,7 +105,7 @@ BOOL ReleaseSemaphoreCE (SYNCHHANDLE hSemCE, LONG cReleaseCount, LPLONG lpPrevio
/* Gain access to the object to assure that the release count
would not cause the total count to exceed the maximum. */
__try
// __try
{
WaitForSingleObject (hSemCE->hMutex, INFINITE);
/* reply only if asked to */
......@@ -113,7 +115,9 @@ BOOL ReleaseSemaphoreCE (SYNCHHANDLE hSemCE, LONG cReleaseCount, LPLONG lpPrevio
{
SetLastError (SYNCH_ERROR);
Result = FALSE;
__leave;
// __leave;
ReleaseMutex (hSemCE->hMutex);
return Result;
}
hSemCE->CurCount += cReleaseCount;
......@@ -122,10 +126,10 @@ BOOL ReleaseSemaphoreCE (SYNCHHANDLE hSemCE, LONG cReleaseCount, LPLONG lpPrevio
SetEvent (hSemCE->hEvent);
}
__finally
{
// __finally
// {
ReleaseMutex (hSemCE->hMutex);
}
// }
return Result;
}
......
@ ARM code version of Blit1to2.
@
@ @author Robin Watts (robin@wss.co.uk)
.text
.global Blit1to2ARM
@ Reads a width x height block of 8 bpp pixels from srcPtr, looks
@ them up in the palette at map, and stores them as 16bpp pixels
@ at dstPtr. srcPitch and dstPitch give information about how to
@ find the next lines.
Blit1to2ARM:
@ r0 = srcPtr
@ r1 = srcPitch
@ r2 = dstPtr
@ r3 = dstPitch
MOV r12,r13
STMFD r13!,{r4-r11,r14}
LDMIA r12,{r4-r6}
@ r4 = width
@ r5 = height
@ r6 = map
SUBS r5,r5,#1 @ while (--height)
BLT end
height_loop:
SUBS r7,r4,#5 @ r7= width_minus_5
BLE thin
width_loop:
@ Have to do at least 6 here
LDRB r8, [r0],#1 @ r8 = *src++
LDRB r9, [r0],#1 @ r9 = *src++
LDRB r10,[r0],#1 @ r10= *src++
LDRB r11,[r0],#1 @ r11= *src++
LDRB r12,[r0],#1 @ r12= *src++
LDRB r14,[r0],#1 @ r14= *src++
ADD r8, r8, r8 @ r8 = 2*r8
ADD r9, r9, r9 @ r9 = 2*r9
ADD r10,r10,r10 @ r10= 2*r10
ADD r11,r11,r11 @ r11= 2*r11
ADD r12,r12,r12 @ r12= 2*r12
ADD r14,r14,r14 @ r14= 2*r14
LDRH r8, [r6,r8] @ r8 = map[r8]
LDRH r9, [r6,r9] @ r9 = map[r9]
LDRH r10,[r6,r10] @ r10= map[r10]
LDRH r11,[r6,r11] @ r11= map[r11]
LDRH r12,[r6,r12] @ r12= map[r12]
LDRH r14,[r6,r14] @ r14= map[r14]
SUBS r7,r7,#6 @ r7 = width_minus_5 -= 6
STRH r8, [r2],#2 @ *dstPtr++ = r8
STRH r9, [r2],#2 @ *dstPtr++ = r9
STRH r10,[r2],#2 @ *dstPtr++ = r10
STRH r11,[r2],#2 @ *dstPtr++ = r11
STRH r12,[r2],#2 @ *dstPtr++ = r12
STRH r14,[r2],#2 @ *dstPtr++ = r14
BGT width_loop @ width_minus_5>0 => 6+ left to do
thin:
ADDS r7,r7,#5 @ r7 = width (width <= 5)
BEQ end_thin
thin_lp:
LDRB r8,[r0],#1 @ r8 = *src++
SUBS r7,r7,#1 @ r7 = width--
@ Stall
ADD r8,r8,r8 @ r8 = 2*r8
LDRH r8,[r6,r8] @ r8 = map[r8]
@ Stall
@ Stall
STRH r8,[r2],#2 @ *dstPtr++ = r8
BGT thin_lp
end_thin:
ADD r2,r2,r3 @ dstPtr += dstPitch
ADD r0,r0,r1 @ srcPtr += srcPitch
SUBS r5,r5,#1
BGE height_loop
end:
LDMFD r13!,{r4-r11,PC}
......@@ -102,6 +102,28 @@ static char rcsid =
#include "SDL_memops.h"
#include "SDL_RLEaccel_c.h"
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) && defined(ARM)
/* Crashes the compiler otherwise !!! */
int SDL_RLESurface(SDL_Surface *surface) {
return -1;
}
int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) {
return -1;
}
int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) {
return -1;
}
void SDL_UnRLESurface(SDL_Surface *surface, int recode) {
}
#else
#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define MMX_ASMBLIT
#endif
......@@ -1950,4 +1972,4 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode)
}
}
#endif // HPC workaround
......@@ -81,8 +81,25 @@ static void Blit1to1(SDL_BlitInfo *info)
#define HI 0
#define LO 1
#endif
#if defined(ARM)
void Blit1to2ARM(Uint8 *src, int srcskip,
Uint8 *dst, int dstskip,
int width, int height,
Uint16 *map);
#endif
static void Blit1to2(SDL_BlitInfo *info)
{
#if defined(ARM)
Blit1to2ARM(info->s_pixels,
info->s_skip,
info->d_pixels,
info->d_skip,
info->d_width,
info->d_height,
(Uint16 *)info->table);
#else
#ifndef USE_DUFFS_LOOP
int c;
#endif
......@@ -189,6 +206,7 @@ static void Blit1to2(SDL_BlitInfo *info)
}
}
#endif /* USE_DUFFS_LOOP */
#endif /* ARM */
}
static void Blit1to3(SDL_BlitInfo *info)
{
......
......@@ -362,6 +362,9 @@ extern VideoBootStrap AALIB_bootstrap;
#ifdef ENABLE_WINDIB
extern VideoBootStrap WINDIB_bootstrap;
#endif
#ifdef ENABLE_WINGAPI
extern VideoBootStrap WINGAPI_bootstrap;
#endif
#ifdef ENABLE_DIRECTX
extern VideoBootStrap DIRECTX_bootstrap;
#endif
......
......@@ -81,6 +81,9 @@ static VideoBootStrap *bootstrap[] = {
#ifdef ENABLE_DIRECTX
&DIRECTX_bootstrap,
#endif
#ifdef ENABLE_WINGAPI
&WINGAPI_bootstrap,
#endif
#ifdef ENABLE_WINDIB
&WINDIB_bootstrap,
#endif
......@@ -881,6 +884,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
(SDL_VideoSurface->flags&SDL_HWSURFACE) &&
!(SDL_VideoSurface->flags&SDL_DOUBLEBUF))
) ) {
SDL_CreateShadowSurface(bpp);
if ( SDL_ShadowSurface == NULL ) {
SDL_SetError("Couldn't create shadow surface");
......
......@@ -41,6 +41,12 @@ static char rcsid =
#include "SDL_syswm_c.h"
#include "SDL_main.h"
#ifndef _WIN32_WCE
#include "SDL_dibvideo.h"
#else
#include "../wingapi/SDL_gapivideo.h"
#endif
#ifdef WMMSG_DEBUG
#include "wmmsg.h"
#endif
......@@ -48,11 +54,58 @@ static char rcsid =
#ifdef _WIN32_WCE
#define NO_GETKEYBOARDSTATE
#define NO_CHANGEDISPLAYSETTINGS
#undef WM_MOUSELEAVE
#define DM_DISPLAYORIENTATION 0x00800000L
typedef struct _devicemode {
WCHAR dmDeviceName[CCHDEVICENAME];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DWORD dmFields;
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
short dmScale;
short dmCopies;
short dmDefaultSource;
short dmPrintQuality;
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
WCHAR dmFormName[CCHFORMNAME];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
DWORD dmDisplayFlags;
DWORD dmDisplayFrequency;
DWORD dmDisplayOrientation;
} DEVMODE_2003, *LPDEVMODE_2003;
#define DMDO_0 0
#define DMDO_90 1
#define DMDO_180 2
#define DMDO_270 4
typedef LONG (*tChangeDisplaySettingsEx)(LPCTSTR, LPDEVMODE_2003, HWND, DWORD, LPVOID);
tChangeDisplaySettingsEx dynChangeDisplaySettingsEx = NULL;
LONG initDspMode = -1;
int currDspMode = -1;
#define ROTATE_NONE 0
#define ROTATE_LEFT 1
#define ROTATE_RIGHT 2
#define ROTATE_FLIP 3
#endif
/* The window we use for everything... */
#ifdef _WIN32_WCE
LPWSTR SDL_Appname = NULL;
#undef WM_GETMINMAXINFO
static int translatelandscape = 0, isLandscape = 0;
#else
LPSTR SDL_Appname = NULL;
#endif
......@@ -94,6 +147,7 @@ static void SDL_RestoreDesktopMode(void)
}
#ifdef WM_MOUSELEAVE
#warning "warn"
/*
Special code to handle mouse leave events - this sucks...
http://support.microsoft.com/support/kb/articles/q183/1/07.asp
......@@ -174,6 +228,151 @@ static void WIN_GetKeyboardState(void)
#endif /* !NO_GETKEYBOARDSTATE */
}
#ifdef _WIN32_WCE
static LONG getDisplayMode(void)
{
DEVMODE_2003 devMode;
LONG r;
memset(&devMode, 0, sizeof(devMode));
devMode.dmSize = sizeof(devMode);
devMode.dmFields = DM_DISPLAYORIENTATION;
r = dynChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_TEST, NULL);
debugLog("SDL: orientation %d", devMode.dmDisplayOrientation);
return devMode.dmDisplayOrientation;
}
static int deRotate(LONG neworientation)
{
if (initDspMode == DMDO_0) {
if (neworientation == DMDO_0)
return ROTATE_NONE;
else if (neworientation == DMDO_90)
return ROTATE_LEFT;
else if (neworientation == DMDO_270)
return ROTATE_RIGHT;
} else if (initDspMode == DMDO_90) {
if (neworientation == DMDO_0)
return ROTATE_LEFT;
else if (neworientation == DMDO_90)
return ROTATE_NONE;
else if (neworientation == DMDO_270)
return ROTATE_FLIP;
} else if (initDspMode == DMDO_270) {
if (neworientation == DMDO_0)
return ROTATE_RIGHT;
else if (neworientation == DMDO_90)
return ROTATE_FLIP;
else if (neworientation == DMDO_270)
return ROTATE_NONE;
}
return ROTATE_NONE;
}
void InitializeDisplayOrientation(void)
{
HINSTANCE h = NULL;
/* mark the initial orientation if the device does not support orient. reporting */
if ( (unsigned int) GetSystemMetrics(SM_CXSCREEN) < (unsigned int) GetSystemMetrics(SM_CYSCREEN) ) //portrait
isLandscape = 0;
else
isLandscape = 1;
/* orientation call, if exists */
if (!dynChangeDisplaySettingsEx)
{
h = LoadLibrary(TEXT("coredll.dll"));
if (!h)
debugLog("SDL: Cannot load coredll");
else {
dynChangeDisplaySettingsEx = (tChangeDisplaySettingsEx) GetProcAddress(h, TEXT("ChangeDisplaySettingsEx"));
FreeLibrary(h);
}
}
if (dynChangeDisplaySettingsEx) {
currDspMode = initDspMode = getDisplayMode();
} else {
debugLog("SDL: No orientation reporting");
initDspMode = -1;
}
}
#endif
void transform(SDL_RotateAttr rotate, char ozone, Sint16 *x, Sint16 *y) {
SDL_VideoDevice *this = current_video;
Sint16 rotatedX;
Sint16 rotatedY;
if (ozone) {
*x = *x * 2;
*y = *y * 2;
}
/* first, derotate if possible */
if (initDspMode != -1) {
int w = displayProperties.cxWidth;
int h = displayProperties.cyHeight;
if (initDspMode != DMDO_0)
{
w ^= h;
h ^= w;
w ^= h;
}
if (currDspMode == ROTATE_LEFT) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
*y = h - *y;
} else if (currDspMode == ROTATE_RIGHT) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
*x = w - *x;
} else if (currDspMode == ROTATE_FLIP) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
} else if (translatelandscape) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
*y = displayProperties.cyHeight - *y;
}
/* then, rotate sccording to surface */
switch(rotate) {
case SDL_ROTATE_NONE:
*x -= padWidth;
*y -= padHeight;
break;
case SDL_ROTATE_LEFT:
if (!SDL_VideoSurface)
break;
*x -= padHeight;
*y -= padWidth;
rotatedX = SDL_VideoSurface->w - *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
break;
case SDL_ROTATE_RIGHT:
if (!SDL_VideoSurface)
break;
*x -= padHeight;
*y -= padWidth;
rotatedX = *y;
rotatedY = SDL_VideoSurface->h - *x;
*x = rotatedX;
*y = rotatedY;
break;
}
}
/* The main Win32 event handler
DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it
*/
......@@ -182,14 +381,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_VideoDevice *this = current_video;
static int mouse_pressed = 0;
static int in_window = 0;
#ifdef WMMSG_DEBUG
fprintf(stderr, "Received windows message: ");
if ( msg > MAX_WMMSG ) {
fprintf(stderr, "%d", msg);
debugLog("SDL: Received windows message: %d -- 0x%X, 0x%X\n", msg, wParam, lParam);
} else {
fprintf(stderr, "%s", wmtab[msg]);
debugLog("SDL: Received windows message: %s -- 0x%X, 0x%X\n", wmtab[msg], wParam, lParam);
}
fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
#endif
switch (msg) {
......@@ -213,6 +411,8 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_RestoreGameMode();
}
}
if (this->hidden && this->hidden->gapiFuncs.dynamicGXResume)
this->hidden->gapiFuncs.dynamicGXResume();
posted = SDL_PrivateAppActive(1, appstate);
WIN_GetKeyboardState();
} else {
......@@ -232,6 +432,8 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_RestoreDesktopMode();
}
}
if (this->hidden && this->hidden->gapiFuncs.dynamicGXResume)
this->hidden->gapiFuncs.dynamicGXSuspend();
posted = SDL_PrivateAppActive(0, appstate);
}
return(0);
......@@ -274,6 +476,8 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
posted = SDL_PrivateMouseMotion(0, 1, x, y);
}
} else {
if (SDL_VideoSurface)
transform(rotation, ozoneHack, &x, &y);
posted = SDL_PrivateMouseMotion(0, 0, x, y);
}
}
......@@ -362,7 +566,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} else {
x = (Sint16)LOWORD(lParam);
y = (Sint16)HIWORD(lParam);
if (SDL_VideoSurface)
transform(rotation, ozoneHack, &x, &y);
}
#ifdef _WIN32_WCE
/* Since stylus movements are not continuous */
posted = SDL_PrivateMouseMotion(0, 0, x, y);
#endif
posted = SDL_PrivateMouseButton(
state, button, x, y);
}
......@@ -536,6 +746,48 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
return(0);
#ifdef _WIN32_WCE
/* mark the device's orientation at startup */
case WM_CREATE: {
OSVERSIONINFO wv = { 0 };
wv.dwOSVersionInfoSize = sizeof(LPOSVERSIONINFO);
GetVersionEx(&wv);
debugLog("SDL: Device is %s, OS version %d.%d build %d", (isLandscape) ? "landscape" : "portrait",
wv.dwMajorVersion, wv.dwMinorVersion, wv.dwBuildNumber );
InitializeDisplayOrientation();
}
break; // fall through to the default handler
case WM_SETTINGCHANGE: {
if (initDspMode == -1) {
int oldtmp = translatelandscape;
if ( (unsigned int) GetSystemMetrics(SM_CXSCREEN) < (unsigned int) GetSystemMetrics(SM_CYSCREEN) ) //portrait
translatelandscape = (isLandscape == 0) ? 0 : 1;
else
translatelandscape = (isLandscape == 1) ? 0 : 1;
debugLog("SDL: Caught WM_SETTINGCHANGE %d -> %d (flag %d)", oldtmp, translatelandscape, isLandscape);
} else {
currDspMode = deRotate(getDisplayMode());
switch (currDspMode)
{
case ROTATE_NONE:
debugLog("SDL: Selecting no translation");
break;
case ROTATE_LEFT:
debugLog("SDL: Selecting left translation");
break;
case ROTATE_RIGHT:
debugLog("SDL: Selecting right translation");
break;
case ROTATE_FLIP:
debugLog("SDL: Selecting flip translation");
break;
}
}
}
break; // fall through to the default handler
#endif
default: {
/* Special handling by the video driver */
if (HandleMessage) {
......
......@@ -251,6 +251,7 @@ void WIN_UpdateMouse(_THIS)
/* Check to see if we need to enter or leave mouse relative mode */
void WIN_CheckMouseMode(_THIS)
{
#ifndef _WIN32_WCE
/* If the mouse is hidden and input is grabbed, we use relative mode */
if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
(this->input_grab != SDL_GRAB_OFF) ) {
......@@ -258,4 +259,7 @@ void WIN_CheckMouseMode(_THIS)
} else {
mouse_relative = 0;
}
#else
mouse_relative = 0;
#endif
}
......@@ -59,17 +59,79 @@ static BOOL prev_shiftstates[2];
and give him a chance to handle some messages. */
static WNDPROC userWindowProc = NULL;
#ifdef _WIN32_WCE
WPARAM rotateKey(WPARAM key, SDL_RotateAttr direction) {
switch (direction) {
case SDL_ROTATE_NONE:
return key;
case SDL_ROTATE_LEFT:
switch (key) {
case VK_UP:
return VK_RIGHT;
case VK_RIGHT:
return VK_DOWN;
case VK_DOWN:
return VK_LEFT;
case VK_LEFT:
return VK_UP;
}
case SDL_ROTATE_RIGHT:
switch (key) {
case VK_UP:
return VK_LEFT;
case VK_RIGHT:
return VK_UP;
case VK_DOWN:
return VK_RIGHT;
case VK_LEFT:
return VK_DOWN;
}
}
return key;
}
#endif
/* The main Win32 event handler */
LONG
DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
extern int posted;
MSG tmpmsg;
static int dropnextvklwinup = 0;
switch (msg) {
case WM_SYSKEYDOWN:
//case WM_SYSKEYDOWN:
case WM_KEYDOWN: {
SDL_keysym keysym;
#ifdef _WIN32_WCE
// Drop spurious keystrokes
if ( wParam == VK_F20 || // VK_ROCKER with arrow keys
wParam == VK_F21 || // VK_DPAD with arrow keys
wParam == VK_F23 // VK_ACTION with dpad enter
)
return 0;
if (wParam == VK_LWIN && PeekMessage(&tmpmsg, NULL, 0, 0, PM_NOREMOVE)) // drop VK_LWIN messages if they're part of a chord
if (tmpmsg.message == WM_KEYDOWN && tmpmsg.wParam != VK_LWIN) {
#ifdef WMMSG_DEBUG
debugLog("SDL: DROPPING chorded VK_LWIN DOWN");
#endif
dropnextvklwinup = 1;
return 0;
}
// Rotate key if necessary
if (rotation != SDL_ROTATE_NONE)
wParam = rotateKey(wParam, rotation);
#endif
/* Ignore repeated keys */
if ( lParam&REPEATED_KEYMASK ) {
return(0);
......@@ -100,35 +162,45 @@ LONG
wParam = VK_LMENU;
break;
}
#ifdef NO_GETKEYBOARDSTATE
/* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
if ( SDL_TranslateUNICODE ) {
MSG m;
m.hwnd = hwnd;
m.message = msg;
m.wParam = wParam;
m.lParam = lParam;
m.time = 0;
if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
GetMessage(&m, hwnd, 0, WM_USER);
wParam = m.wParam;
} else {
wParam = 0;
}
} else {
wParam = 0;
}
#endif /* NO_GETKEYBOARDSTATE */
posted = SDL_PrivateKeyboard(SDL_PRESSED,
TranslateKey(wParam,HIWORD(lParam),&keysym,1));
#ifdef _WIN32_WCE
TranslateKey(wParam,HIWORD(lParam),&keysym,1);
if (keysym.sym != SDLK_UNKNOWN) // drop keys w/ 0 keycode
posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
#ifdef WMMSG_DEBUG
else
debugLog("SDL: DROPPING SDLK_UNKNOWN DOWN");
#endif
#else
posted = SDL_PrivateKeyboard(SDL_PRESSED,TranslateKey(wParam,HIWORD(lParam),&keysym,1));
#endif
}
return(0);
case WM_SYSKEYUP:
//case WM_SYSKEYUP:
case WM_KEYUP: {
SDL_keysym keysym;
#ifdef _WIN32_WCE
// Drop spurious keystrokes
if ( wParam == VK_F20 || // VK_ROCKER with arrow keys
wParam == VK_F21 || // VK_DPAD with arrow keys
wParam == VK_F23 // VK_ACTION with dpad enter
)
return 0;
if (dropnextvklwinup && wParam == VK_LWIN) { // drop VK_LWIN messages if they're part of a chord
#ifdef WMMSG_DEBUG
debugLog("SDL: DROPPING chorded VK_LWIN UP");
#endif
dropnextvklwinup = 0;
return 0;
}
// Rotate key if necessary
if (rotation != SDL_ROTATE_NONE)
wParam = rotateKey(wParam, rotation);
#endif
switch (wParam) {
case VK_CONTROL:
if ( lParam&EXTENDED_KEYMASK )
......@@ -155,8 +227,17 @@ LONG
wParam = VK_LMENU;
break;
}
posted = SDL_PrivateKeyboard(SDL_RELEASED,
TranslateKey(wParam,HIWORD(lParam),&keysym,0));
#ifdef _WIN32_WCE
TranslateKey(wParam,HIWORD(lParam),&keysym,0);
if (keysym.sym != SDLK_UNKNOWN) // drop keys w/ 0 keycode
posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
#ifdef WMMSG_DEBUG
else
debugLog("SDL: DROPPING SDLK_UNKNOWN UP");
#endif
#else
posted = SDL_PrivateKeyboard(SDL_RELEASED,TranslateKey(wParam,HIWORD(lParam),&keysym,0));
#endif
}
return(0);
......@@ -242,6 +323,7 @@ void DIB_InitOSKeymap(_THIS)
VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
#ifndef _WIN32_WCE
VK_keymap[VK_A] = SDLK_a;
VK_keymap[VK_B] = SDLK_b;
VK_keymap[VK_C] = SDLK_c;
......@@ -268,6 +350,34 @@ void DIB_InitOSKeymap(_THIS)
VK_keymap[VK_X] = SDLK_x;
VK_keymap[VK_Y] = SDLK_y;
VK_keymap[VK_Z] = SDLK_z;
#else
VK_keymap['A'] = SDLK_a;
VK_keymap['B'] = SDLK_b;
VK_keymap['C'] = SDLK_c;
VK_keymap['D'] = SDLK_d;
VK_keymap['E'] = SDLK_e;
VK_keymap['F'] = SDLK_f;
VK_keymap['G'] = SDLK_g;
VK_keymap['H'] = SDLK_h;
VK_keymap['I'] = SDLK_i;
VK_keymap['J'] = SDLK_j;
VK_keymap['K'] = SDLK_k;
VK_keymap['L'] = SDLK_l;
VK_keymap['M'] = SDLK_m;
VK_keymap['N'] = SDLK_n;
VK_keymap['O'] = SDLK_o;
VK_keymap['P'] = SDLK_p;
VK_keymap['Q'] = SDLK_q;
VK_keymap['R'] = SDLK_r;
VK_keymap['S'] = SDLK_s;
VK_keymap['T'] = SDLK_t;
VK_keymap['U'] = SDLK_u;
VK_keymap['V'] = SDLK_v;
VK_keymap['W'] = SDLK_w;
VK_keymap['X'] = SDLK_x;
VK_keymap['Y'] = SDLK_y;
VK_keymap['Z'] = SDLK_z;
#endif
VK_keymap[VK_DELETE] = SDLK_DELETE;
VK_keymap[VK_NUMPAD0] = SDLK_KP0;
......@@ -311,6 +421,15 @@ void DIB_InitOSKeymap(_THIS)
VK_keymap[VK_F13] = SDLK_F13;
VK_keymap[VK_F14] = SDLK_F14;
VK_keymap[VK_F15] = SDLK_F15;
VK_keymap[VK_F16] = SDLK_F16;
VK_keymap[VK_F17] = SDLK_F17;
VK_keymap[VK_F18] = SDLK_F18;
VK_keymap[VK_F19] = SDLK_F19;
VK_keymap[VK_F20] = SDLK_F20;
VK_keymap[VK_F21] = SDLK_F21;
VK_keymap[VK_F22] = SDLK_F22;
VK_keymap[VK_F23] = SDLK_F23;
VK_keymap[VK_F24] = SDLK_F24;
VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
......@@ -334,6 +453,15 @@ void DIB_InitOSKeymap(_THIS)
prev_shiftstates[0] = FALSE;
prev_shiftstates[1] = FALSE;
#ifdef _WIN32_WCE
VK_keymap[0xC1] = SDLK_APP1;
VK_keymap[0xC2] = SDLK_APP2;
VK_keymap[0xC3] = SDLK_APP3;
VK_keymap[0xC4] = SDLK_APP4;
VK_keymap[0xC5] = SDLK_APP5;
VK_keymap[0xC6] = SDLK_APP6;
#endif
}
static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
......@@ -365,8 +493,15 @@ int DIB_CreateWindow(_THIS)
#ifndef CS_BYTEALIGNCLIENT
#define CS_BYTEALIGNCLIENT 0
#endif
#ifndef _WIN32_WCE
SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
#else
//SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW, 0);
SDL_RegisterApp("SDL_app", CS_HREDRAW | CS_VREDRAW, 0);
#endif
if ( SDL_windowid ) {
// FIXME
#ifndef _WIN32_WCE
SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't get user specified window");
......@@ -378,16 +513,29 @@ int DIB_CreateWindow(_THIS)
*/
userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
#endif
} else {
#ifndef _WIN32_WCE
SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
#else
SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, WS_VISIBLE | WS_POPUP,
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, SDL_Instance, NULL);
SetWindowPos(SDL_Window, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
#endif
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't create window");
return(-1);
}
#ifndef _WIN32_WCE
ShowWindow(SDL_Window, SW_HIDE);
#endif
}
return(0);
}
......
This diff is collapsed.
......@@ -30,10 +30,21 @@ static char rcsid =
#include <windows.h>
/* Rotation direction */
typedef enum {
SDL_ROTATE_NONE,
SDL_ROTATE_LEFT,
SDL_ROTATE_RIGHT
} SDL_RotateAttr;
/* Private display data */
struct SDL_PrivateVideoData {
HBITMAP screen_bmp;
HPALETTE screen_pal;
void *work_pixels; /* if the display needs to be rotated, memory allocated by the API */
void *rotation_pixels; /* if the display needs to be rotated, memory allocated by the code */
SDL_RotateAttr rotation;
char ozoneHack; /* force stylus translation if running without Hi Res flag */
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
......@@ -44,5 +55,9 @@ struct SDL_PrivateVideoData {
#define screen_pal (this->hidden->screen_pal)
#define SDL_nummodes (this->hidden->SDL_nummodes)
#define SDL_modelist (this->hidden->SDL_modelist)
#define work_pixels (this->hidden->work_pixels)
#define rotation (this->hidden->rotation)
#define rotation_pixels (this->hidden->rotation_pixels)
#define ozoneHack (this->hidden->ozoneHack)
#endif /* _SDL_dibvideo_h */
@ ARM code version of rotation routines.
@
@ @author Robin Watts (robin@wss.co.uk)
@
@ When rotating a block of memory to the screen, the key facts to bear in
@ mind are:
@ * Screen memory is uncached - therefore to get best performance we want
@ to write runs of horizontal pixels so the write buffer can kick in and
@ merge the buffered writes.
@ * Reading large numbers of pixels to be written out horizontally, pulls
@ in lots of cache lines. We need to be careful not to cache bust here.
@ * The 16 or 32 way set associativity for screens can hurt us here too.
@
@ A good compromise is therefore to write out in bursts of 4 horizontal
@ pixels at once.
.text
.global ARM_rotate
@ Reads block of w*h pixels from srcPtr (addressed by srcPixStep,
@ srcLineStep) and stores them at dst (addressed by dstPixStep,
@ dstLineStep), converting palette by table lookup in convertPalette.
ARM_rotate:
@ r0 = destPtr
@ r1 = srcPtr
@ r2 = w
@ r3 = h
@ r4 = dstLineStep
@ r5 = srcPixStep - e.g. 480
@ r6 = srcLineStep - e.g. 2 or -2
MOV r12,r13
STMFD r13!,{r4-r11,r14}
LDMFD r12,{r4-r6}
@ For simplicity, we will think about width/height in terms of
@ destination.
AND r7,r0,#6
MOV r7,r7,LSR #1
AND r7,r7,#3 @ r7 = Number over a multiple of 4 we start on
RSB r7,r7,#4 @ r7 = Number to do first time.
rotate_loop:
CMP r7,r2
MOVGT r7,r2 @ r7 = width to do this time
SUBS r7,r7,#4 @ r7 = width-4
BLT thin @ less than 4 pixels wide
SUB r8,r4,#6 @ r8 = dstLineStep-6
x_loop_4:
@ In this routine we will copy a 4 pixel wide stripe
ADD r9,r5,r5,LSL #1 @ r9 = 3*srcPixStep
SUB r9,r6,r9 @ r9 = srcLineStep-3*srcPixStep
MOV r7,r3 @ r7 = h
y_loop_4:
@ r9 >= 0, so at least 4 to do.
LDRH r10,[r1],r5 @ r10 = *(src)
LDRH r11,[r1],r5 @ r11 = *(src+srcPixStep)
LDRH r12,[r1],r5 @ r12 = *(src+srcPixStep*2)
LDRH r14,[r1],r9 @ r14 = *(src+srcPixStep*3) src+=srcLineStep
STRH r10,[r0],#2 @ *(ptr) = r10
STRH r11,[r0],#2 @ *(ptr+2) = r11
STRH r12,[r0],#2 @ *(ptr+4) = r12
STRH r14,[r0],r8 @ *(ptr+6) = r14 ptr += dstLineStep
SUBS r7,r7,#1 @ h--
BGT y_loop_4
MUL r10,r3,r6
ADD r1,r1,r5,LSL #2
SUB r1,r1,r10
MUL r10,r3,r4
ADD r0,r0,#8
SUB r0,r0,r10
SUBS r2,r2,#4 @ r2 = w -= 4
BEQ rotate_end @ if w = 0, none left.
SUBS r7,r2,#4 @ r7 = w - 4
BGE x_loop_4 @ if 4 or more left, go back.
thin:
MOV r14,r3 @ r14 = h
thin_lp:
ADDS r7,r7,#2 @ Always do 1. GE => do 2. GT => do 3
BGE just_2
BGT just_3
@ Just do a 1 pixel wide stripe. Either the last pixel stripe, or
@ the first pixel stripe to align us.
y_loop_1:
LDRH r10,[r1],r6
SUBS r14,r14,#1
STRH r10,[r0],r4
BGT y_loop_1
MUL r10,r3,r6 @ How much to step r1 back to undo this line?
ADD r1,r1,r5 @ Move r1 on by srcPixStep
SUB r1,r1,r10 @ Move r1 back by amount just added on
MUL r10,r3,r4 @ How much to step r0 back to undo this line?
ADD r0,r0,#2 @ Move r0 on by dstPixStep
SUB r0,r0,r10 @ Move r0 back by amount just added on
SUBS r2,r2,#1 @ If we havent finished (i.e. we were doing
MOV r7,r2 @ the first pixel rather than the last one)
BGT rotate_loop @ then jump back to do some more
rotate_end:
LDMFD r13!,{r4-r11,PC}
just_2:
@ Just do a 2 pixel wide stripe. Either the last stripe, or
@ the first stripe to align us.
SUB r9,r6,r5 @ r9 = srcLineStep - srcPixStep
SUB r8,r4,#2 @ r8 = dstLineStep - 2
y_loop_2:
LDRH r10,[r1],r5
LDRH r11,[r1],r9
SUBS r14,r14,#1
STRH r10,[r0],#2
STRH r11,[r0],r8
BGT y_loop_2
MUL r10,r3,r6 @ How much to step r1 back to undo this line?
ADD r1,r1,r5,LSL #1 @ Move r1 on by srcPixStep*2
SUB r1,r1,r10 @ Move r1 back by amount just added on
MUL r10,r3,r4 @ How much to step r0 back to undo this line?
ADD r0,r0,#4 @ Move r0 on by dstPixStep*2
SUB r0,r0,r10 @ Move r0 back by amount just added on
SUBS r2,r2,#2 @ If we havent finished (i.e. we were doing
MOV r7,r2 @ the first stripe rather than the last one)
BGT rotate_loop @ then jump back to do some more
LDMFD r13!,{r4-r11,PC}
just_3:
SUB r9,r6,r5,LSL #1 @ r9 = srcLineStep - srcPixStep
SUB r8,r4,#4 @ r8 = dstLineStep - 2
y_loop_3:
LDRH r10,[r1],r5
LDRH r11,[r1],r5
LDRH r12,[r1],r9
STRH r10,[r0],#2
STRH r11,[r0],#2
STRH r12,[r0],r8
SUBS r14,r14,#1
BGT y_loop_3
MUL r10,r3,r6 @ How much to step r1 back to undo this line?
ADD r1,r1,r5 @ Move r1 on by srcPixStep*3
ADD r1,r1,r5,LSL #1
SUB r1,r1,r10 @ Move r1 back by amount just added on
MUL r10,r3,r4 @ How much to step r0 back to undo this line?
ADD r0,r0,#6 @ Move r0 on by dstPixStep*3
SUB r0,r0,r10 @ Move r0 back by amount just added on
SUBS r2,r2,#3 @ If we havent finished (i.e. we were doing
MOV r7,r2 @ the first stripe rather than the last one)
BGT rotate_loop @ then jump back to do some more
LDMFD r13!,{r4-r11,PC}
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_gapivideo.h,v 1.1 2004/02/02 23:25:35 lemure Exp $";
#endif
#ifndef _SDL_gapivideo_h
#define _SDL_gapivideo_h
#include <windows.h>
/* -------------------------------------------------------------------------------------------- */
/* From gx.h, since it's not really C compliant */
struct GXDisplayProperties {
DWORD cxWidth;
DWORD cyHeight; // notice lack of 'th' in the word height.
long cbxPitch; // number of bytes to move right one x pixel - can be negative.
long cbyPitch; // number of bytes to move down one y pixel - can be negative.
long cBPP; // # of bits in each pixel
DWORD ffFormat; // format flags.
};
struct GXKeyList {
short vkUp; // key for up
POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates.
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
};
#define kfLandscape 0x8 // Screen is rotated 270 degrees
#define kfPalette 0x10 // Pixel values are indexes into a palette
#define kfDirect 0x20 // Pixel values contain actual level information
#define kfDirect555 0x40 // 5 bits each for red, green and blue values in a pixel.
#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel
#define kfDirect888 0x100 // 8 bits each for red, green and blue values in a pixel.
#define kfDirect444 0x200 // 4 red, 4 green, 4 blue
#define kfDirectInverted 0x400
#define GX_FULLSCREEN 0x01 // for OpenDisplay()
/* 2003 SE GAPI emulation */
#define GETRAWFRAMEBUFFER 0x00020001
#define FORMAT_565 1
#define FORMAT_555 2
#define FORMAT_OTHER 3
/* -------------------------------------------------------------------------------------------- */
/* Rotation direction */
typedef enum {
SDL_ROTATE_NONE,
SDL_ROTATE_LEFT,
SDL_ROTATE_RIGHT
} SDL_RotateAttr;
/* GAPI video mode */
typedef enum {
GAPI_NONE = 0,
GAPI_DIRECT_565,
GAPI_DIRECT_555,
GAPI_MONO,
GAPI_PALETTE
} SDL_GAPIVideoMode;
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
/* GAPI functions definitions */
typedef struct GXDisplayProperties (*tGXDisplayProperties)(void);
typedef int (*tGXOpenDisplay)(HWND, unsigned long);
typedef void* (*tGXBeginDraw)(void);
typedef int (*tGXVoidFunction)(void);
/* Private display data */
struct GAPI_funcs {
tGXDisplayProperties dynamicGXGetDisplayProperties;
tGXOpenDisplay dynamicGXOpenDisplay;
tGXVoidFunction dynamicGXCloseDisplay;
tGXBeginDraw dynamicGXBeginDraw;
tGXVoidFunction dynamicGXEndDraw;
tGXVoidFunction dynamicGXSuspend;
tGXVoidFunction dynamicGXResume;
};
struct GAPI_properties {
unsigned char invert;
int colorscale;
int dstPixelstep;
int dstLinestep;
int startOffset;
SDL_GAPIVideoMode videoMode;
};
#define MAX_CLR 0x100
struct palette_properties {
unsigned char *palRed;
unsigned char *palGreen;
unsigned char *palBlue;
unsigned short *pal;
};
struct SDL_PrivateVideoData {
/* --- <Hack> --- begin with DIB private structure to allow DIB events code sharing */
HBITMAP screen_bmp;
HPALETTE screen_pal;
void *work_pixels; /* if the display needs to be rotated, memory allocated by the API */
void *rotation_pixels; /* if the display needs to be rotated, memory allocated by the code */
SDL_RotateAttr rotation;
char ozoneHack; /* force stylus translation if running without Hi Res flag */
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
/* --- </Hack> --- */
int w, h;
void *gapiBuffer;
HPALETTE screenPal;
struct GAPI_funcs gapiFuncs;
struct GAPI_properties gapiProperties;
struct GXDisplayProperties displayProps;
int srcLinestep;
int srcPixelstep;
int padWidth;
int padHeight;
unsigned short *convertPalette;
};
#define gapiBuffer (this->hidden->gapiBuffer)
#define mainSurfaceWidth (this->hidden->w)
#define mainSurfaceHeight (this->hidden->h)
#define rotation (this->hidden->rotation)
#define ozoneHack (this->hidden->ozoneHack)
#define displayProperties (this->hidden->displayProps)
#define screenPal (this->hidden->screenPal)
#define GXGetDisplayProperties (this->hidden->gapiFuncs.dynamicGXGetDisplayProperties)
#define GXOpenDisplay (this->hidden->gapiFuncs.dynamicGXOpenDisplay)
#define GXCloseDisplay (this->hidden->gapiFuncs.dynamicGXCloseDisplay)
#define GXBeginDraw (this->hidden->gapiFuncs.dynamicGXBeginDraw)
#define GXEndDraw (this->hidden->gapiFuncs.dynamicGXEndDraw)
#define GXSuspend (this->hidden->gapiFuncs.dynamicGXSuspend)
#define GXResume (this->hidden->gapiFuncs.dynamicGXResume)
#define invert (this->hidden->gapiProperties.invert)
#define colorscale (this->hidden->gapiProperties.colorscale)
#define videoMode (this->hidden->gapiProperties.videoMode)
#define srcPixelstep (this->hidden->srcPixelstep)
#define srcLinestep (this->hidden->srcLinestep)
#define dstPixelstep (this->hidden->gapiProperties.dstPixelstep)
#define dstLinestep (this->hidden->gapiProperties.dstLinestep)
#define startOffset (this->hidden->gapiProperties.startOffset)
#define padWidth (this->hidden->padWidth)
#define padHeight (this->hidden->padHeight)
#define convertPalette (this->hidden->convertPalette)
#endif /* _SDL_gapivideo_h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment