From 335038b8453ceb938d47c51b62756bf30e63f331 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Tue, 25 Nov 2003 04:36:25 +0000 Subject: [PATCH] stuff to play mve's in WinCE --- ChangeLog | 3 ++ libmve/decoder8.c | 6 ++-- libmve/mve_main.c | 84 +++++++++++++++++++++++++++++++++++++++++++++-- libmve/mvelib.c | 2 ++ libmve/mveplay.c | 32 ++++++++++++++++-- 5 files changed, 119 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cf2cc8d..3bcab9d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-11-24 Bradley Bell + * libmve/decoder8.c, libmve/mve_main.c, libmve/mvelib.c, + libmve/mveplay.c: stuff to play mve's in WinCE + * arch/win32/findfile.c: unused functions... * README: stuff diff --git a/libmve/decoder8.c b/libmve/decoder8.c index 53cbb1e7..a676e00b 100644 --- a/libmve/decoder8.c +++ b/libmve/decoder8.c @@ -225,7 +225,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, unsi { case 0x0: /* block is copied from block in current frame */ - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1)); + copyFrame(*pFrame, *pFrame + ((unsigned char *)g_vBackBuf2 - (unsigned char *)g_vBackBuf1)); case 0x1: /* block is unchanged from two frames ago */ *pFrame += 8; @@ -283,7 +283,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, unsi y = -8 + BH */ relClose(*(*pData)++, &x, &y); - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1) + x + y*g_width); + copyFrame(*pFrame, *pFrame + ((unsigned char *)g_vBackBuf2 - (unsigned char *)g_vBackBuf1) + x + y*g_width); *pFrame += 8; --*pDataRemain; break; @@ -296,7 +296,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, unsi */ x = (signed char)*(*pData)++; y = (signed char)*(*pData)++; - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1) + x + y*g_width); + copyFrame(*pFrame, *pFrame + ((unsigned char *)g_vBackBuf2 - (unsigned char *)g_vBackBuf1) + x + y*g_width); *pFrame += 8; *pDataRemain -= 2; break; diff --git a/libmve/mve_main.c b/libmve/mve_main.c index 1f933e0a..3c941617 100644 --- a/libmve/mve_main.c +++ b/libmve/mve_main.c @@ -1,14 +1,25 @@ -/* $Id: mve_main.c,v 1.3 2003-06-10 04:46:16 btb Exp $ */ +/* $Id: mve_main.c,v 1.4 2003-11-25 04:36:25 btb Exp $ */ #include #include +#ifdef _WIN32_WCE +# include +#endif + +#ifdef _WIN32_WCE // should really be checking for "Pocket PC" somehow +# define LANDSCAPE +#endif + #include #include "libmve.h" static SDL_Surface *g_screen; +#ifdef LANDSCAPE +static SDL_Surface *real_screen; +#endif static unsigned char g_palette[768]; static int g_truecolor; @@ -35,6 +46,57 @@ int main(int c, char **v) return doPlay(v[1]); } + +#ifdef LANDSCAPE +/* Create a new rotated surface for drawing */ +SDL_Surface *CreateRotatedSurface(SDL_Surface *s) +{ + return(SDL_CreateRGBSurface(s->flags, s->h, s->w, + s->format->BitsPerPixel, + s->format->Rmask, + s->format->Gmask, + s->format->Bmask, + s->format->Amask)); +} + +/* Used to copy the rotated scratch surface to the screen */ +void BlitRotatedSurface(SDL_Surface *from, SDL_Surface *to) +{ + + int bpp = from->format->BytesPerPixel; + int w=from->w, h=from->h, pitch=to->pitch; + int i,j; + Uint8 *pfrom, *pto, *to0; + + SDL_LockSurface(from); + SDL_LockSurface(to); + pfrom=(Uint8 *)from->pixels; + to0=(Uint8 *) to->pixels+pitch*(w-1); + for (i=0; iflags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) + SDL_Flip(real_screen); + else + SDL_UpdateRect(real_screen, 0, 0, 0, 0); +#else if ( (g_screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) SDL_Flip(g_screen); else SDL_UpdateRects(g_screen, 1, &destRect); +#endif SDL_FreeSurface(sprite); } @@ -135,6 +205,7 @@ static int doPlay(const char *filename) { int result; int done = 0; + int bpp = 0; FILE *mve; MVE_videoSpec vSpec; @@ -156,7 +227,16 @@ static int doPlay(const char *filename) MVE_getVideoSpec(&vSpec); - g_screen = SDL_SetVideoMode(vSpec.screenWidth, vSpec.screenHeight, vSpec.truecolor?16:8, SDL_ANYFORMAT); +#ifndef _WIN32_WCE // doesn't like to change bpp? + bpp = vSpec.truecolor?16:8; +#endif + +#ifdef LANDSCAPE + real_screen = SDL_SetVideoMode(vSpec.screenHeight, vSpec.screenWidth, bpp, SDL_FULLSCREEN); + g_screen = CreateRotatedSurface(real_screen); +#else + g_screen = SDL_SetVideoMode(vSpec.screenWidth, vSpec.screenHeight, bpp, SDL_ANYFORMAT); +#endif g_truecolor = vSpec.truecolor; diff --git a/libmve/mvelib.c b/libmve/mvelib.c index 902e9cec..d4954c85 100644 --- a/libmve/mvelib.c +++ b/libmve/mvelib.c @@ -1,8 +1,10 @@ #include // for mem* functions +#ifndef _WIN32_WCE #include #include #include #include +#endif #include "mvelib.h" diff --git a/libmve/mveplay.c b/libmve/mveplay.c index b4a0b52a..74b547ce 100644 --- a/libmve/mveplay.c +++ b/libmve/mveplay.c @@ -1,4 +1,4 @@ -/* $Id: mveplay.c,v 1.14 2003-06-10 04:46:16 btb Exp $ */ +/* $Id: mveplay.c,v 1.15 2003-11-25 04:36:25 btb Exp $ */ #ifdef HAVE_CONFIG_H #include #endif @@ -9,6 +9,7 @@ //#define DEBUG #include +#ifndef _WIN32_WCE #include #include #include @@ -16,6 +17,9 @@ #include #include #include +#else +# include +#endif #if defined(AUDIO) #include @@ -125,7 +129,22 @@ struct timespec int nanosleep(struct timespec *ts, void *rem); #endif -#ifdef __WIN32 +#ifdef _WIN32_WCE +int gettimeofday(struct timeval *tv, void *tz) +{ + static int counter = 0; + DWORD now; + + counter++; + now = GetTickCount(); + + tv->tv_sec = now / 1000; + tv->tv_usec = (now % 1000) * 1000 + counter; + + return 0; +} + +#elif defined(__WIN32) #include int gettimeofday(struct timeval *tv, void *tz) @@ -151,7 +170,12 @@ int nanosleep(struct timespec *ts, void *rem) static int create_timer_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { + +#ifndef _WIN32_WCE __extension__ long long temp; +#else + long temp; +#endif if (timer_created) return 1; @@ -212,7 +236,9 @@ static void do_timer_wait(void) ts.tv_nsec += 1000000000UL; --ts.tv_sec; } -#ifdef __CYGWIN__ +#ifdef _WIN32_WCE + Sleep(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); +#elif defined(__CYGWIN__) usleep(ts.tv_sec * 1000000 + ts.tv_nsec / 1000); #else if (nanosleep(&ts, NULL) == -1 && errno == EINTR) -- 2.39.2