Skip to content
Permalink
Browse files

Updated for embedded Visual C++ 4.0

  • Loading branch information
slouken committed Aug 20, 2002
1 parent d773491 commit 68a0a5cdec33dcef047428e6554e5ee8841c4767
@@ -39,6 +39,7 @@ EXTRA_DIST = \
Borland.zip \
VisualC.html \
VisualC.zip \
VisualCE.zip \
MPWmake.sea.bin \
CWprojects.sea.bin \
PBProjects.tar.gz \
@@ -1,8 +1,7 @@

NOTE:
SDL is NOT SUPPORTED on the WinCE platform! This is for experimental
purposes only.
Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip

NOTE:
There are several SDL features not available in the WinCE port of SDL.

- DirectX is not yet available
BIN +9.13 KB VisualCE.zip
Binary file not shown.
@@ -30,9 +30,10 @@ static char rcsid =

/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */

#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__) || \
defined(QWS)
#if defined(WIN32) || defined(_WIN32) || \
(defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(macintosh) || defined(__APPLE__) || \
defined(__SYMBIAN32__) || defined(QWS)

#ifdef __cplusplus
#define C_LINKAGE "C"
@@ -63,7 +63,7 @@ static int Audio_Available(void)

/* Version check DSOUND.DLL (Is DirectX okay?) */
dsound_ok = 0;
DSoundDLL = LoadLibrary("DSOUND.DLL");
DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
if ( DSoundDLL != NULL ) {
/* We just use basic DirectSound, we're okay */
/* Yay! */
@@ -95,7 +95,7 @@ static int Audio_Available(void)
* to fall back to the DIB driver. */
if (dsound_ok) {
/* DirectSoundCaptureCreate was added in DX5 */
if (!GetProcAddress(DSoundDLL, "DirectSoundCaptureCreate"))
if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate")))
dsound_ok = 0;

}
@@ -121,10 +121,10 @@ static int DX5_Load(void)
int status;

DX5_Unload();
DSoundDLL = LoadLibrary("DSOUND.DLL");
DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
if ( DSoundDLL != NULL ) {
DSoundCreate = (void *)GetProcAddress(DSoundDLL,
"DirectSoundCreate");
TEXT("DirectSoundCreate"));
}
if ( DSoundDLL && DSoundCreate ) {
status = 0;
@@ -189,7 +189,7 @@ AudioBootStrap DSOUND_bootstrap = {
static void SetDSerror(const char *function, int code)
{
static const char *error;
static char errbuf[BUFSIZ];
static char errbuf[1024];

errbuf[0] = 0;
switch (code) {
@@ -225,6 +225,9 @@ int console_main(int argc, char *argv[])

/* Exit cleanly, calling atexit() functions */
exit(0);

/* Hush little compiler, don't you cry... */
return(0);
}

/* This is where execution begins [windowed apps] */
@@ -33,8 +33,8 @@ static char rcsid =
#include "SDL_error.h"

#ifdef _WIN32_WCE
#define USE_GETTICKCOUNT
#define USE_SETTIMER
//#define USE_GETTICKCOUNT
//#define USE_SETTIMER
#endif

#define TIME_WRAP_VALUE (~(DWORD)0)
@@ -42,6 +42,7 @@ static char rcsid =
#ifndef _WIN32_WCE
#define HAVE_OPENGL
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

@@ -53,7 +53,11 @@ static char rcsid =
#define DINPUT_FULLSCREEN() DDRAW_FULLSCREEN()

/* The main window -- and a function to set it for the audio */
extern const char *SDL_Appname;
#ifdef _WIN32_WCE
extern LPWSTR SDL_Appname;
#else
extern LPSTR SDL_Appname;
#endif
extern HINSTANCE SDL_Instance;
extern HWND SDL_Window;
extern const char *SDL_windowid;
@@ -47,10 +47,15 @@ static char rcsid =

#ifdef _WIN32_WCE
#define NO_GETKEYBOARDSTATE
#define NO_CHANGEDISPLAYSETTINGS
#endif

/* The window we use for everything... */
const char *SDL_Appname = NULL;
#ifdef _WIN32_WCE
LPWSTR SDL_Appname = NULL;
#else
LPSTR SDL_Appname = NULL;
#endif
HINSTANCE SDL_Instance = NULL;
HWND SDL_Window = NULL;
RECT SDL_bounds = {0, 0, 0, 0};
@@ -578,21 +583,22 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
class.hCursor = NULL;
#ifdef _WIN32_WCE
{
/* WinCE uses the UNICODE version */
int nLen = strlen(name)+1;
LPWSTR lpszW = alloca(nLen*2);
MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen);
class.hIcon = LoadImage(hInst, lpszW, IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
class.lpszMenuName = NULL;
class.lpszClassName = lpszW;
/* WinCE uses the UNICODE version */
int nLen = strlen(name)+1;
SDL_Appname = malloc(nLen*2);
MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
}
#else
class.hIcon = LoadImage(hInst, name, IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
class.lpszMenuName = "(none)";
class.lpszClassName = name;
{
int nLen = strlen(name)+1;
SDL_Appname = malloc(nLen);
strcpy(SDL_Appname, name);
}
#endif /* _WIN32_WCE */
class.hIcon = LoadImage(hInst, SDL_Appname, IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
class.lpszMenuName = NULL;
class.lpszClassName = SDL_Appname;
class.hbrBackground = NULL;
class.hInstance = hInst;
class.style = style;
@@ -606,7 +612,6 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
SDL_SetError("Couldn't register application class");
return(-1);
}
SDL_Appname = name;
SDL_Instance = hInst;

#ifdef WM_MOUSELEAVE
@@ -27,7 +27,9 @@ static char rcsid =

/* WGL implementation of SDL OpenGL support */

#ifdef HAVE_OPENGL
#include "SDL_opengl.h"
#endif
#include "SDL_error.h"
#include "SDL_lowvideo.h"
#include "SDL_wingl_c.h"
@@ -264,10 +266,6 @@ void WIN_GL_SwapBuffers(_THIS)
SwapBuffers(GL_hdc);
}

#endif /* HAVE_OPENGL */

#ifdef HAVE_OPENGL

void WIN_GL_UnloadLibrary(_THIS)
{
if ( this->gl_config.driver_loaded ) {
@@ -333,28 +333,9 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in

int DIB_CreateWindow(_THIS)
{
#ifdef _WIN32_WCE
/* WinCE uses the UNICODE version */
int nLen;
LPWSTR lpszW;

if ( SDL_RegisterApp("SDL_app", 0, 0) != 0 ) {
return -1;
}

nLen = strlen(SDL_Appname) + 1;
lpszW = alloca(nLen * 2);

MultiByteToWideChar(CP_ACP, 0, "SDL_App", -1, lpszW, nLen);

SDL_Window = CreateWindow(lpszW, lpszW, WS_VISIBLE,
0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't create window");
return(-1);
}
ShowWindow(SDL_Window, SW_HIDE);
#else
#ifndef CS_BYTEALIGNCLIENT
#define CS_BYTEALIGNCLIENT 0
#endif
SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
if ( SDL_windowid ) {
SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
@@ -376,8 +357,6 @@ int DIB_CreateWindow(_THIS)
}
ShowWindow(SDL_Window, SW_HIDE);
}
#endif /* _WIN32_WCE */

return(0);
}

@@ -53,6 +53,15 @@ static char rcsid =
#define NO_CHANGEDISPLAYSETTINGS
#define NO_GAMMA_SUPPORT
#endif
#ifndef WS_MAXIMIZE
#define WS_MAXIMIZE 0
#endif
#ifndef SWP_NOCOPYBITS
#define SWP_NOCOPYBITS 0
#endif
#ifndef PC_NOCOLLAPSE
#define PC_NOCOLLAPSE 0
#endif

/* Initialization/Query functions */
static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat);
@@ -143,11 +152,11 @@ static SDL_VideoDevice *DIB_CreateDevice(int devindex)
device->SetGammaRamp = DIB_SetGammaRamp;
device->GetGammaRamp = DIB_GetGammaRamp;
#ifdef HAVE_OPENGL
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
device->GL_GetProcAddress = WIN_GL_GetProcAddress;
device->GL_GetAttribute = WIN_GL_GetAttribute;
device->GL_MakeCurrent = WIN_GL_MakeCurrent;
device->GL_SwapBuffers = WIN_GL_SwapBuffers;
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
device->GL_GetProcAddress = WIN_GL_GetProcAddress;
device->GL_GetAttribute = WIN_GL_GetAttribute;
device->GL_MakeCurrent = WIN_GL_MakeCurrent;
device->GL_SwapBuffers = WIN_GL_SwapBuffers;
#endif
device->SetCaption = WIN_SetWMCaption;
device->SetIcon = WIN_SetWMIcon;
@@ -440,10 +449,8 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
(WS_POPUP);
const DWORD windowstyle =
(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
#ifndef _WIN32_WCE
const DWORD resizestyle =
(WS_THICKFRAME|WS_MAXIMIZEBOX);
#endif
int binfo_size;
BITMAPINFO *binfo;
HDC hdc;
@@ -455,12 +462,10 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
/* See whether or not we should center the window */
was_visible = IsWindowVisible(SDL_Window);

#ifdef HAVE_OPENGL
/* Clean up any GL context that may be hanging around */
if ( current->flags & SDL_OPENGL ) {
WIN_GL_ShutDown(this);
}
#endif /* HAVE_OPENGL */

/* Recalculate the bitmasks if necessary */
if ( bpp == current->format->BitsPerPixel ) {
@@ -542,9 +547,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
}

style = GetWindowLong(SDL_Window, GWL_STYLE);
#ifndef _WIN32_WCE
style &= ~(resizestyle|WS_MAXIMIZE);
#endif
if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
style &= ~windowstyle;
style |= directstyle;
@@ -562,13 +565,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
style &= ~directstyle;
style |= windowstyle;
if ( flags & SDL_RESIZABLE ) {
#ifndef _WIN32_WCE
style |= resizestyle;
#endif
video->flags |= SDL_RESIZABLE;
}
}
#ifndef _WIN32_WCE
#if WS_MAXIMIZE
if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
}
@@ -659,23 +660,15 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
bounds.top = 0;
bounds.right = video->w;
bounds.bottom = video->h;
#ifndef _WIN32_WCE
AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
#else
AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0);
#endif
AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
width = bounds.right-bounds.left;
height = bounds.bottom-bounds.top;
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
if ( y < 0 ) { /* Cover up title bar for more client area */
y -= GetSystemMetrics(SM_CYCAPTION)/2;
}
#ifndef _WIN32_WCE
swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
#else
swp_flags = (SWP_FRAMECHANGED | SWP_SHOWWINDOW);
#endif
if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
swp_flags |= SWP_NOMOVE;
}
@@ -689,15 +682,13 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
SetForegroundWindow(SDL_Window);
}

#ifdef HAVE_OPENGL
/* Set up for OpenGL */
if ( flags & SDL_OPENGL ) {
if ( WIN_GL_SetupWindow(this) < 0 ) {
return(NULL);
}
video->flags |= SDL_OPENGL;
}
#endif /* HAVE_OPENGL */

/* We're live! */
return(video);
@@ -760,11 +751,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
entries[i].peRed = colors[i].r;
entries[i].peGreen = colors[i].g;
entries[i].peBlue = colors[i].b;
#ifndef _WIN32_WCE
entries[i].peFlags = PC_NOCOLLAPSE;
#else
entries[i].peFlags = 0;
#endif
}
SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
SelectPalette(hdc, screen_pal, FALSE);
@@ -917,11 +904,9 @@ void DIB_VideoQuit(_THIS)
ShowWindow(SDL_Window, SW_HIDE);
}
#endif
#ifdef HAVE_OPENGL
if ( this->screen->flags & SDL_OPENGL ) {
WIN_GL_ShutDown(this);
}
#endif /* HAVE_OPENGL */
this->screen->pixels = NULL;
}
if ( screen_bmp ) {

0 comments on commit 68a0a5c

Please sign in to comment.