Removed wince support

This commit is contained in:
jsalmon3 2003-10-16 00:36:26 +00:00
parent 139d90d3dd
commit 30a81f3e78
11 changed files with 6 additions and 466 deletions

View file

@ -36,9 +36,7 @@
#include <string.h>
#include <stdio.h>
#if !defined(_MSC_VER) || !defined(_WIN32_WCE)
#include <time.h>
#endif
#include "stratagus.h"

View file

@ -49,9 +49,6 @@
#else // _MSC_VER
#ifdef _WIN32_WCE
#define R_OK 1 // FIXME: correct?
#else
#define R_OK 4
#define F_OK 0
#include <sys/types.h>
@ -64,7 +61,6 @@
#define PATH_MAX _MAX_PATH
#define S_ISDIR(x) ((x) & _S_IFDIR)
#define S_ISREG(x) ((x) & _S_IFREG)
#endif
#endif // _MSC_VER

View file

@ -51,15 +51,6 @@
#define USE_WINSOCK
#if !defined(_MSC_VER) || defined(_WIN32_WCE)
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
#define WINVER 0x0400
#endif
#endif
#ifdef __MINGW32__
#define DrawIcon WinDrawIcon
#define EndMenu WinEndMenu

View file

@ -134,7 +134,6 @@
#define inline __inline /// Fix m$ brain damage
#define alloca _alloca /// I hope this works with all VC..
#ifndef _WIN32_WCE
#pragma warning(disable:4244) // Conversion from double to uchar
#pragma warning(disable:4761) // Integral size mismatch
#define snprintf _snprintf /// Unix -> dumm
@ -142,7 +141,6 @@
#include <string.h>
#define strdup _strdup
#define strncasecmp strnicmp
#endif
#ifndef __FUNCTION__
@ -513,13 +511,6 @@ extern long isqrt(long num);
== Misc
============================================================================*/
#if !defined(_MSC_VER) || defined(_WIN32_WCE)
#ifndef max
/// max macro
#define max(n1,n2) (((n1)<(n2)) ? (n2) : (n1))
#endif
#endif
/// bits macro
#define BitsOf(n) (sizeof(n)*8)

View file

@ -37,9 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(_MSC_VER) || !defined(_WIN32_WCE)
#include <time.h>
#endif
#include "stratagus.h"
#include "unit.h"

View file

@ -44,9 +44,7 @@
#ifdef BSD
#include <inttypes.h>
#else
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
#include <windows.h>
#endif
#include <stdint.h>
#endif // BSD

View file

@ -43,7 +43,7 @@
#ifdef BSD
#include <inttypes.h>
#else
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
#ifdef _MSC_VER
#define DrawIcon WinDrawIcon
#define EndMenu WinEndMenu
#include <winsock2.h>

View file

@ -182,17 +182,15 @@ extern void beos_init( int argc, char **argv );
#ifndef _MSC_VER
#include <unistd.h>
#endif
#if defined(__CYGWIN__)
#ifdef __CYGWIN__
#include <getopt.h>
#endif
#if defined(_MSC_VER)
#ifdef _MSC_VER
//#include "etlib/getopt.h"
extern char* optarg;
extern int optind;
#ifndef _WIN32_WCE
extern int getopt(int argc, char *const*argv, const char *opt);
#endif
#endif
#ifdef USE_SDL
#include "SDL.h"

View file

@ -40,7 +40,7 @@
#include "stratagus.h"
#if defined(_MSC_VER)
#ifdef _MSC_VER
#undef NOUSER
#endif
#include "video.h"

View file

@ -1,4 +1,4 @@
SRC += src/video/X11.c src/video/cursor.c src/video/deco.c src/video/font.c src/video/graphic.c src/video/linedraw.c src/video/new_X11.c src/video/png.c src/video/sdl.c src/video/sprite.c src/video/sweepline.c src/video/video.c src/video/wince.c
SRC += src/video/X11.c src/video/cursor.c src/video/deco.c src/video/font.c src/video/graphic.c src/video/linedraw.c src/video/new_X11.c src/video/png.c src/video/sdl.c src/video/sprite.c src/video/sweepline.c src/video/video.c
HDRS += src/video/intern_video.h src/video/sweepline.h
OBJ += src/video/$(OBJDIR)/X11.o src/video/$(OBJDIR)/cursor.o src/video/$(OBJDIR)/deco.o src/video/$(OBJDIR)/font.o src/video/$(OBJDIR)/graphic.o src/video/$(OBJDIR)/linedraw.o src/video/$(OBJDIR)/new_X11.o src/video/$(OBJDIR)/png.o src/video/$(OBJDIR)/sdl.o src/video/$(OBJDIR)/sprite.o src/video/$(OBJDIR)/sweepline.o src/video/$(OBJDIR)/video.o src/video/$(OBJDIR)/wince.o
OBJ += src/video/$(OBJDIR)/X11.o src/video/$(OBJDIR)/cursor.o src/video/$(OBJDIR)/deco.o src/video/$(OBJDIR)/font.o src/video/$(OBJDIR)/graphic.o src/video/$(OBJDIR)/linedraw.o src/video/$(OBJDIR)/new_X11.o src/video/$(OBJDIR)/png.o src/video/$(OBJDIR)/sdl.o src/video/$(OBJDIR)/sprite.o src/video/$(OBJDIR)/sweepline.o src/video/$(OBJDIR)/video.o
MISC += src/video/_clip_rectangle

View file

@ -1,430 +0,0 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name wince.c - WinCE video support. */
//
// (c) Copyright 2001-2003 by Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 dated June, 1991.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// $Id$
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#include "stratagus.h"
#ifdef USE_WINCE // {
#include <stdlib.h>
#include "video.h"
#include "font.h"
#include "map.h"
#include "interface.h"
#include "network.h"
#include "ui.h"
#include "sound_server.h"
#include "sound.h"
#include "interface.h"
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Sync
----------------------------------------------------------------------------*/
/**
** Initialise video sync.
**
** @note SDL has only a maximum resolution of 10 ms.
**
** @see VideoSyncSpeed
*/
global void SetVideoSync(void)
{
DebugLevel0Fn("%d\n" _C_ (100*1000/CYCLES_PER_SECOND)/VideoSyncSpeed);
}
/*----------------------------------------------------------------------------
-- Video
----------------------------------------------------------------------------*/
/**
** Initialze the video part for WinCE.
*/
global void InitVideoSdl(void)
{
// Initialize the WinCE library
// Initialize the display
if( !VideoWidth ) {
VideoWidth = DEFAULT_VIDEO_WIDTH;
VideoHeight = DEFAULT_VIDEO_HEIGHT;
}
VideoBpp=16;
VideoDepth=16;
DebugLevel3Fn("Video init ready %d %d\n" _C_ VideoDepth _C_ VideoBpp);
}
/**
** Invalidate some area
**
** @param x screen pixel X position.
** @param y screen pixel Y position.
** @param w width of rectangle in pixels.
** @param h height of rectangle in pixels.
*/
global void InvalidateArea(int x,int y,int w,int h)
{
}
/**
** Invalidate whole window
*/
global void Invalidate(void)
{
}
/**
** Wait for interactive input event for one frame.
**
** Handles system events, joystick, keyboard, mouse.
** Handles the network messages.
** Handles the sound queue.
**
** All events available are fetched. Sound and network only if available.
** Returns if the time for one frame is over.
**
** @param callbacks Call backs that handle the events.
*/
global void WaitEventsOneFrame(const EventCallback* callbacks)
{
struct timeval tv;
fd_set rfds;
fd_set wfds;
int maxfd;
Uint32 i;
SDL_Event event[1];
if( SoundFildes==-1 ) {
SoundOff=1;
}
InputMouseTimeout(callbacks,SDL_GetTicks());
for(;;) {
#if 1
static Uint32 LastTick;
//
// Time of frame over? This makes the CPU happy. :(
//
i=WinCE_GetTicks();
while( i>=LastTick ) {
++VideoInterrupts;
LastTick+=(100*1000/CYCLES_PER_SECOND)/VideoSyncSpeed;
}
#endif
//
// Prepare select
//
maxfd=0;
tv.tv_sec=tv.tv_usec=0;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
//
// Network
//
if( NetworkFildes!=-1 ) {
if( NetworkFildes>maxfd ) {
maxfd=NetworkFildes;
}
FD_SET(NetworkFildes,&rfds);
}
//
// Sound
//
if( !SoundOff && !SoundThreadRunning ) {
if( SoundFildes>maxfd ) {
maxfd=SoundFildes;
}
FD_SET(SoundFildes,&wfds);
}
#if 0
maxfd=select(maxfd+1,&rfds,&wfds,NULL
,(i=SDL_PollEvent(event)) ? &tv : NULL);
#else
// QUICK HACK to fix the event/timer problem
// The timer code didn't interrupt the select call.
// Perhaps I could send a signal to the process
// Not very nice, but this is the problem if you use other libraries
// The event handling of SDL is wrong designed = polling only.
// There is hope on SDL 1.3 which will have this fixed.
maxfd=select(maxfd+1,&rfds,&wfds,NULL,&tv);
i=SDL_PollEvent(event);
#endif
if ( i ) { // Handle SDL event
SdlDoEvent(callbacks,event);
}
if( maxfd>0 ) {
//
// Sound
//
if( !SoundOff && !SoundThreadRunning
&& FD_ISSET(SoundFildes,&wfds) ) {
callbacks->SoundReady();
}
//
// Not more input and network in syn and time for frame over
//
if( !i && NetworkInSync && VideoInterrupts ) {
break;
}
//
// Network
//
if( NetworkFildes!=-1 && FD_ISSET(NetworkFildes,&rfds) ) {
callbacks->NetworkEvent();
}
}
//
// Not more input and time for frame over: return
//
if( !i && VideoInterrupts ) {
break;
}
}
//
// Prepare return, time for one frame is over.
//
VideoInterrupts=0;
}
/**
** Maps RGB to a hardware dependent pixel.
**
** @param r Red color.
** @param g Green color.
** @param b Blue color.
**
** @return A hardware dependent pixel.
*/
global unsigned long VideoMapRGB(int r, int g, int b)
{
DebugCheck(!Screen);
return SDL_MapRGB(Screen->format, r, g, b);
}
/**
** Create a new hardware dependent palette palette.
**
** @param palette Hardware independent palette.
**
** @return A hardware dependent pixel table.
*/
global VMemType *VideoCreateNewPalette(const Palette * palette)
{
int i;
void *pixels;
if (!Screen) { // no init
return NULL;
}
switch (VideoBpp) {
case 8:
pixels = malloc(256 * sizeof(VMemType8));
break;
case 15:
case 16:
pixels = malloc(256 * sizeof(VMemType16));
break;
case 24:
pixels = malloc(256 * sizeof(VMemType24));
break;
case 32:
pixels = malloc(256 * sizeof(VMemType32));
break;
default:
DebugLevel0Fn("Unknown depth\n");
return NULL;
}
//
// Convert each palette entry into hardware format.
//
for (i = 0; i < 256; ++i) {
int r;
int g;
int b;
int v;
char *vp;
r = (palette[i].r) & 0xFF;
g = (palette[i].g) & 0xFF;
b = (palette[i].b) & 0xFF;
v = r + g + b;
// Apply global saturation,contrast and brightness
r = ((((r * 3 - v) * TheUI.Saturation + v * 100)
* TheUI.Contrast)
+ TheUI.Brightness * 25600 * 3) / 30000;
g = ((((g * 3 - v) * TheUI.Saturation + v * 100)
* TheUI.Contrast)
+ TheUI.Brightness * 25600 * 3) / 30000;
b = ((((b * 3 - v) * TheUI.Saturation + v * 100)
* TheUI.Contrast)
+ TheUI.Brightness * 25600 * 3) / 30000;
// Boundings
r = r < 0 ? 0 : r > 255 ? 255 : r;
g = g < 0 ? 0 : g > 255 ? 255 : g;
b = b < 0 ? 0 : b > 255 ? 255 : b;
// -> Video
switch (VideoBpp) {
case 8:
((VMemType8 *) pixels)[i] =
SDL_MapRGB(Screen->format, r, g, b);
break;
case 15:
case 16:
((VMemType16 *) pixels)[i] =
SDL_MapRGB(Screen->format, r, g, b);
break;
case 24:
v = SDL_MapRGB(Screen->format, r, g, b);
vp = (char *)(&v);
((VMemType24 *) pixels)[i].a = vp[0]; // endian safe ?
((VMemType24 *) pixels)[i].b = vp[1];
((VMemType24 *) pixels)[i].c = vp[2];
break;
case 32:
((VMemType32 *) pixels)[i] =
SDL_MapRGB(Screen->format, r, g, b);
break;
}
}
return pixels;
}
/**
** Check video interrupt.
**
** Display and count too slow frames.
*/
global void CheckVideoInterrupts(void)
{
if( VideoInterrupts ) {
//DebugLevel1("Slow frame\n");
IfDebug(
if (InterfaceState == IfaceStateNormal) {
VideoDrawText(TheUI.MapX+10,TheUI.MapY+10,GameFont,"SLOW FRAME!!");
}
);
++SlowFrameCounter;
}
}
/**
** Realize video memory.
*/
global void RealizeVideoMemory(void)
{
}
/**
** Toggle grab mouse.
**
** @param mode Wanted mode, 1 grab, -1 not grab, 0 toggle.
*/
global void ToggleGrabMouse(int mode __attribute__((unused)))
{
}
#endif // } USE_WINCE
#ifdef _WIN32_WCE // {
/*----------------------------------------------------------------------------
-- General Win32 CE support functions
----------------------------------------------------------------------------*/
/**
** abort not available
*/
global volatile void abort(void)
{
ExitFatal(-1);
}
/**
** strdup other name
*/
global char* strdup(const char* strSource)
{
return _strdup(strSource);
}
/**
** perror not supported
*/
global void perror(const char* msg)
{
printf("%s",msg);
// FIXME: more is missing
}
#endif // } _WIN32_WCE
//@}