CleanUp
This commit is contained in:
parent
a6fc8c2375
commit
bdd9f47bf7
7 changed files with 178 additions and 186 deletions
|
@ -68,19 +68,19 @@ const char CursorTypeType[] = "cursor-type";
|
|||
*/
|
||||
CursorType* Cursors;
|
||||
|
||||
CursorStates CursorState; /// current cursor state (point,...)
|
||||
int CursorAction; /// action for selection
|
||||
int CursorValue; /// value for CursorAction (spell type f.e.)
|
||||
CursorStates CursorState; ///< current cursor state (point,...)
|
||||
int CursorAction; ///< action for selection
|
||||
int CursorValue; ///< value for CursorAction (spell type f.e.)
|
||||
|
||||
// Event changed mouse position, can alter at any moment
|
||||
int CursorX; /// cursor position on screen X
|
||||
int CursorY; /// cursor position on screen Y
|
||||
int CursorX; ///< cursor position on screen X
|
||||
int CursorY; ///< cursor position on screen Y
|
||||
|
||||
int CursorStartX; /// rectangle started on screen X
|
||||
int CursorStartY; /// rectangle started on screen Y
|
||||
int CursorStartX; ///< rectangle started on screen X
|
||||
int CursorStartY; ///< rectangle started on screen Y
|
||||
|
||||
int SubScrollX; /// pixels the mouse moved while scrolling
|
||||
int SubScrollY; /// pixels the mouse moved while scrolling
|
||||
int SubScrollX; ///< pixels the mouse moved while scrolling
|
||||
int SubScrollY; ///< pixels the mouse moved while scrolling
|
||||
|
||||
/// X position of starting point of selection rectangle, in screen pixels.
|
||||
int CursorStartScrMapX;
|
||||
|
@ -89,7 +89,7 @@ int CursorStartScrMapY;
|
|||
|
||||
|
||||
/*--- DRAW BUILDING CURSOR ------------------------------------------------*/
|
||||
static int BuildingCursor; /// Flag (0/1): last cursor was building
|
||||
static int BuildingCursor; ///< Flag (0/1): last cursor was building
|
||||
|
||||
/// area of tiles covered by building cursor (SX,SY;EX,EY)
|
||||
static int BuildingCursorSX;
|
||||
|
@ -100,11 +100,11 @@ static int BuildingCursorEX;
|
|||
/// area of tiles covered by building cursor (SX,SY;EX,EY)
|
||||
static int BuildingCursorEY;
|
||||
|
||||
UnitType* CursorBuilding; /// building cursor
|
||||
UnitType* CursorBuilding; ///< building cursor
|
||||
|
||||
|
||||
/*--- DRAW SPRITE CURSOR ---------------------------------------------------*/
|
||||
CursorType* GameCursor; /// current shown cursor-type
|
||||
CursorType* GameCursor; ///< current shown cursor-type
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
@ -320,7 +320,7 @@ static void DrawBuildingCursor(void)
|
|||
w = w0;
|
||||
while (w--) {
|
||||
if (f && (CursorBuilding->MustBuildOnTop ||
|
||||
CanBuildOn(mx + w, my + h, MapFogFilterFlags(ThisPlayer, mx + w, my + h,
|
||||
CanBuildOn(mx + w, my + h, MapFogFilterFlags(ThisPlayer, mx + w, my + h,
|
||||
mask & ((NumSelected && !CursorBuilding->BuilderOutside &&
|
||||
Selected[0]->X == mx + w && Selected[0]->Y == my + h) ?
|
||||
~(MapFieldLandUnit | MapFieldSeaUnit) : -1)))) &&
|
||||
|
|
|
@ -53,24 +53,24 @@
|
|||
|
||||
/// Font color mapping
|
||||
typedef struct _font_color_mapping_ {
|
||||
char* ColorName; /// Font color name
|
||||
SDL_Color Color[NumFontColors]; /// Array of colors
|
||||
struct _font_color_mapping_* Next; /// Next pointer
|
||||
char* ColorName; ///< Font color name
|
||||
SDL_Color Color[NumFontColors]; ///< Array of colors
|
||||
struct _font_color_mapping_* Next; ///< Next pointer
|
||||
} FontColorMapping;
|
||||
|
||||
static FontColorMapping* FontColor;
|
||||
static FontColorMapping* FontColor; ///< FIXME
|
||||
|
||||
/// Font color mappings
|
||||
static FontColorMapping* FontColorMappings;
|
||||
|
||||
/// Font mapping
|
||||
typedef struct _font_mapping_ {
|
||||
char* Ident; /// Font name
|
||||
int Font; /// Ident number
|
||||
struct _font_mapping_* Next; /// Next pointer
|
||||
char* Ident; ///< Font name
|
||||
int Font; ///< Ident number
|
||||
struct _font_mapping_* Next; ///< Next pointer
|
||||
} FontMapping;
|
||||
|
||||
static FontMapping* FontMappings;
|
||||
static FontMapping* FontMappings; ///< FIXME
|
||||
|
||||
/**
|
||||
** Fonts table
|
||||
|
@ -79,27 +79,19 @@ static FontMapping* FontMappings;
|
|||
*/
|
||||
static ColorFont Fonts[MaxFonts];
|
||||
|
||||
/// Last text color
|
||||
static FontColorMapping* LastTextColor;
|
||||
/// Default text color
|
||||
static FontColorMapping* DefaultTextColor;
|
||||
/// Reverse text color
|
||||
static FontColorMapping* ReverseTextColor;
|
||||
/// Default normal color index
|
||||
static char* DefaultNormalColorIndex;
|
||||
/// Default reverse color index
|
||||
static char* DefaultReverseColorIndex;
|
||||
static FontColorMapping* LastTextColor; ///< Last text color
|
||||
static FontColorMapping* DefaultTextColor; ///< Default text color
|
||||
static FontColorMapping* ReverseTextColor; ///< Reverse text color
|
||||
static char* DefaultNormalColorIndex; ///< Default normal color index
|
||||
static char* DefaultReverseColorIndex; ///< Default reverse color index
|
||||
|
||||
/// Draw character with current video depth.
|
||||
static void VideoDrawChar(const Graphic*, int, int, int, int, int, int);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
/// Font bitmaps
|
||||
static GLubyte* FontBitmaps[MaxFonts][NumFontColors];
|
||||
/// Font bitmap widths
|
||||
static int FontBitmapWidths[MaxFonts];
|
||||
/// Current font
|
||||
static int CurrentFont;
|
||||
static GLubyte* FontBitmaps[MaxFonts][NumFontColors]; ///< Font bitmaps
|
||||
static int FontBitmapWidths[MaxFonts]; ///< Font bitmap widths
|
||||
static int CurrentFont; ///< Current font
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -235,7 +227,7 @@ int VideoTextLength(unsigned font, const unsigned char* text)
|
|||
if (*s == '<' || *s == '>' || *s == '!') {
|
||||
continue;
|
||||
}
|
||||
if (*s != '~') { // ~~ -> ~
|
||||
if (*s != '~') { // ~~ -> ~
|
||||
isformat = !isformat;
|
||||
continue;
|
||||
}
|
||||
|
@ -283,11 +275,11 @@ static void VideoDrawCharClip(const Graphic* graphic, int gx, int gy, int w, int
|
|||
/**
|
||||
** Draw text with font at x,y clipped/unclipped.
|
||||
**
|
||||
** ~ is special prefix.
|
||||
** ~~ is the ~ character self.
|
||||
** ~! print next character reverse.
|
||||
** ~< start reverse.
|
||||
** ~> switch back to last used color.
|
||||
** ~ is special prefix.
|
||||
** ~~ is the ~ character self.
|
||||
** ~! print next character reverse.
|
||||
** ~< start reverse.
|
||||
** ~> switch back to last used color.
|
||||
**
|
||||
** @param x X screen position
|
||||
** @param y Y screen position
|
||||
|
@ -387,12 +379,12 @@ static int DoDrawText(int x, int y, unsigned font, const unsigned char* text,
|
|||
/**
|
||||
** Draw text with font at x,y unclipped.
|
||||
**
|
||||
** ~ is special prefix.
|
||||
** ~~ is the ~ character self.
|
||||
** ~! print next character reverse.
|
||||
** ~n 0123456789abcdef print text in color 1-16.
|
||||
** ~< start reverse.
|
||||
** ~> switch back to last used color.
|
||||
** ~ is special prefix.
|
||||
** ~~ is the ~ character self.
|
||||
** ~! print next character reverse.
|
||||
** ~n 0123456789abcdef print text in color 1-16.
|
||||
** ~< start reverse.
|
||||
** ~> switch back to last used color.
|
||||
**
|
||||
** @param x X screen position
|
||||
** @param y Y screen position
|
||||
|
@ -894,14 +886,14 @@ void FontsCclRegister(void)
|
|||
lua_register(Lua, "DefineFont", CclDefineFont);
|
||||
lua_register(Lua, "DefineFontColor", CclDefineFontColor);
|
||||
|
||||
// lua_register(Lua, "DefaultTextColors", CclDefaultTextColors);
|
||||
// lua_register(Lua, "TextLength", CclTextLength);
|
||||
// lua_register(Lua, "DrawText", CclDrawText);
|
||||
// lua_register(Lua, "DrawReverseText", CclDrawReverseText);
|
||||
// lua_register(Lua, "DrawTextCentered", CclDrawTextCentered);
|
||||
// lua_register(Lua, "DrawReverseTextCentered", CclDrawReverseTextCentered);
|
||||
// lua_register(Lua, "DrawNumber", CclDrawNumber);
|
||||
// lua_register(Lua, "DrawReverseNumber", CclDrawReverseNumber);
|
||||
// lua_register(Lua, "DefaultTextColors", CclDefaultTextColors);
|
||||
// lua_register(Lua, "TextLength", CclTextLength);
|
||||
// lua_register(Lua, "DrawText", CclDrawText);
|
||||
// lua_register(Lua, "DrawReverseText", CclDrawReverseText);
|
||||
// lua_register(Lua, "DrawTextCentered", CclDrawTextCentered);
|
||||
// lua_register(Lua, "DrawReverseTextCentered", CclDrawReverseTextCentered);
|
||||
// lua_register(Lua, "DrawNumber", CclDrawNumber);
|
||||
// lua_register(Lua, "DrawReverseNumber", CclDrawReverseNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
//*@file intern_video.h @brief The video headerfile for video sources only. */
|
||||
//
|
||||
// (c) Copyright 1999-2002 by Stephan Rasenbergver.
|
||||
// (c) Copyright 1999-2002 by Stephan Rasenbergver.
|
||||
//
|
||||
// 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
|
||||
|
@ -26,7 +26,7 @@
|
|||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
// $Id$
|
||||
// $Id$
|
||||
|
||||
#ifndef __INTERN_VIDEO_H__
|
||||
#define __INTERN_VIDEO_H__
|
||||
|
@ -34,63 +34,63 @@
|
|||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Documentation
|
||||
-- Documentation
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** @file intern_video.h
|
||||
** @file intern_video.h
|
||||
**
|
||||
** THIS HEADER FILE SHOULD ONLY BE INCLUDED BY SOURCE-FILES IN VIDEO !!!
|
||||
** THIS HEADER FILE SHOULD ONLY BE INCLUDED BY SOURCE-FILES IN VIDEO !!!
|
||||
**
|
||||
** This delivers an interface to basic video operations in video.c, while
|
||||
** keeping these detailed operations out of the main include-file video.h
|
||||
** This delivers an interface to basic video operations in video.c, while
|
||||
** keeping these detailed operations out of the main include-file video.h
|
||||
**
|
||||
** @todo FIXME: Currently some interfaces listed in video.h should be
|
||||
** moved in here, this includes possible "extern" declarations in
|
||||
** source-files themselves.
|
||||
** The doxygen docs looks not good, but now contains all info.
|
||||
** @todo FIXME: Currently some interfaces listed in video.h should be
|
||||
** moved in here, this includes possible "extern" declarations in
|
||||
** source-files themselves.
|
||||
** The doxygen docs looks not good, but now contains all info.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
// Direct acces to clipping rectangle for macro CLIP_RECTANGLE
|
||||
extern int ClipX1; /// current clipping top left
|
||||
extern int ClipY1; /// current clipping top left
|
||||
extern int ClipX2; /// current clipping bottom right
|
||||
extern int ClipY2; /// current clipping bottom right
|
||||
extern int ClipX1; /// current clipping top left
|
||||
extern int ClipY1; /// current clipping top left
|
||||
extern int ClipX2; /// current clipping bottom right
|
||||
extern int ClipY2; /// current clipping bottom right
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Macros
|
||||
-- Macros
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Clip rectangle area to clipping rectangle.
|
||||
** This means given arguments can be changed to take the clipping
|
||||
** rectangle into account.
|
||||
** Clip rectangle area to clipping rectangle.
|
||||
** This means given arguments can be changed to take the clipping
|
||||
** rectangle into account.
|
||||
**
|
||||
** @todo FIXME: not easy to debug, but making it a function needs:
|
||||
** - pointers to be able to alter given arguments
|
||||
** - special return value to denote 'outside' clipping region
|
||||
** (which is now handled by a simple return in caller function)
|
||||
** @todo FIXME: not easy to debug, but making it a function needs:
|
||||
** - pointers to be able to alter given arguments
|
||||
** - special return value to denote 'outside' clipping region
|
||||
** (which is now handled by a simple return in caller function)
|
||||
**
|
||||
** @param x int X screen pixel position
|
||||
** @param y int Y screen pixel position
|
||||
** (return value of X and Y can be made larger)
|
||||
** @param width unsigned int width to display
|
||||
** @param height unsigned int height to display
|
||||
** (return value of width and height can be made smaller)
|
||||
** @param x int X screen pixel position
|
||||
** @param y int Y screen pixel position
|
||||
** (return value of X and Y can be made larger)
|
||||
** @param width unsigned int width to display
|
||||
** @param height unsigned int height to display
|
||||
** (return value of width and height can be made smaller)
|
||||
*/
|
||||
#define CLIP_RECTANGLE(x, y, width, height) { \
|
||||
int f; \
|
||||
|
@ -125,27 +125,27 @@ extern int ClipY2; /// current clipping bottom right
|
|||
}
|
||||
|
||||
/**
|
||||
** Clip rectangle area (just like CLIP_RECTANGLE), but also return offsets
|
||||
** (these offsets can be used to skip data when used for sprites and such)
|
||||
** Clip rectangle area (just like CLIP_RECTANGLE), but also return offsets
|
||||
** (these offsets can be used to skip data when used for sprites and such)
|
||||
**
|
||||
** @todo FIXME: not easy to debug, but making it a function needs:
|
||||
** - pointers to be able to alter given arguments
|
||||
** - special return value to denote 'outside' clipping region
|
||||
** (which is now handled by a simple return in caller function)
|
||||
** @todo FIXME: not easy to debug, but making it a function needs:
|
||||
** - pointers to be able to alter given arguments
|
||||
** - special return value to denote 'outside' clipping region
|
||||
** (which is now handled by a simple return in caller function)
|
||||
**
|
||||
** @param x int X screen position
|
||||
** @param y int Y screen position
|
||||
** (return value of X and Y can be made larger)
|
||||
** @param width int width to display
|
||||
** @param height int height to display
|
||||
** (return value of width and height can be made smaller)
|
||||
** @param x int X screen position
|
||||
** @param y int Y screen position
|
||||
** (return value of X and Y can be made larger)
|
||||
** @param width int width to display
|
||||
** @param height int height to display
|
||||
** (return value of width and height can be made smaller)
|
||||
** returns:
|
||||
** @param ofsx int offset X from start of sprite data
|
||||
** @param ofsy int offset Y from start of sprite data
|
||||
** @param endx int offset to skip the remaining data at the
|
||||
** end of each horizontal line of the sprite.
|
||||
** @param ofsx int offset X from start of sprite data
|
||||
** @param ofsy int offset Y from start of sprite data
|
||||
** @param endx int offset to skip the remaining data at the
|
||||
** end of each horizontal line of the sprite.
|
||||
**
|
||||
** @note there was no need for 'endy', as it isn't used to draw sprites..
|
||||
** @note there was no need for 'endy', as it isn't used to draw sprites..
|
||||
*/
|
||||
#define CLIP_RECTANGLE_OFS(x, y, width, height, ofsx, ofsy, endx) { \
|
||||
if (y < ClipY1) { \
|
||||
|
@ -187,10 +187,10 @@ extern int ClipY2; /// current clipping bottom right
|
|||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
//@}
|
||||
|
||||
#endif // !__INTERN_VIDEO_H__
|
||||
#endif // !__INTERN_VIDEO_H__
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -46,23 +46,23 @@
|
|||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Bitmask, denoting a postion left/right/above/below clip rectangle
|
||||
** (mainly used by VideoDrawLineClip)
|
||||
** Bitmask, denoting a postion left/right/above/below clip rectangle
|
||||
** (mainly used by VideoDrawLineClip)
|
||||
*/
|
||||
typedef enum {
|
||||
ClipCodeInside = 0, /// Clipping inside rectangle
|
||||
ClipCodeAbove = 1, /// Clipping above rectangle
|
||||
ClipCodeBelow = 2, /// Clipping below rectangle
|
||||
ClipCodeLeft = 4, /// Clipping left rectangle
|
||||
ClipCodeRight = 8 /// Clipping right rectangle
|
||||
ClipCodeInside = 0, /// Clipping inside rectangle
|
||||
ClipCodeAbove = 1, /// Clipping above rectangle
|
||||
ClipCodeBelow = 2, /// Clipping below rectangle
|
||||
ClipCodeLeft = 4, /// Clipping left rectangle
|
||||
ClipCodeRight = 8 /// Clipping right rectangle
|
||||
} ClipCode;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
|
@ -73,7 +73,7 @@ static void (*VideoDoDrawTransPixel)(Uint32 color, int x, int y, unsigned char a
|
|||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// Pixel
|
||||
// Pixel
|
||||
// ===========================================================================
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
|
@ -258,7 +258,7 @@ void VideoDrawTransVLine(Uint32 color, int x, int y,
|
|||
void VideoDrawVLineClip(Uint32 color, int x, int y, int height)
|
||||
{
|
||||
int w;
|
||||
|
||||
|
||||
w = 1;
|
||||
CLIP_RECTANGLE(x, y, w, height);
|
||||
VideoDrawVLine(color, x, y, height);
|
||||
|
@ -299,7 +299,7 @@ void VideoDrawHLine(Uint32 color, int x, int y, int width)
|
|||
void VideoDrawHLineClip(Uint32 color, int x, int y, int width)
|
||||
{
|
||||
int h;
|
||||
|
||||
|
||||
h = 1;
|
||||
CLIP_RECTANGLE(x, y, width, h);
|
||||
VideoDrawHLine(color, x, y, width);
|
||||
|
@ -1678,7 +1678,7 @@ void VideoFillCircleClip(Uint32 color, int x, int y, int r)
|
|||
} while (cx <= cy);
|
||||
}
|
||||
|
||||
void VideoFillTransCircle(Uint32 color, int x, int y,
|
||||
void VideoFillTransCircle(Uint32 color, int x, int y,
|
||||
int r, unsigned char alpha)
|
||||
{
|
||||
int p;
|
||||
|
|
|
@ -172,7 +172,7 @@ Graphic* LoadGraphicPNG(const char* name)
|
|||
/* Check if all tRNS entries are opaque except one */
|
||||
int i;
|
||||
int t;
|
||||
|
||||
|
||||
t = -1;
|
||||
for (i = 0; i < num_trans; ++i) {
|
||||
if (trans[i] == 0) {
|
||||
|
@ -206,7 +206,7 @@ Graphic* LoadGraphicPNG(const char* name)
|
|||
&color_type, &interlace_type, NULL, NULL);
|
||||
|
||||
/* Allocate the SDL surface to hold the image */
|
||||
Rmask = Gmask = Bmask = Amask = 0 ;
|
||||
Rmask = Gmask = Bmask = Amask = 0 ;
|
||||
if (color_type != PNG_COLOR_TYPE_PALETTE) {
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {
|
||||
Rmask = 0x000000FF;
|
||||
|
@ -271,7 +271,7 @@ Graphic* LoadGraphicPNG(const char* name)
|
|||
palette->colors[i].b = i;
|
||||
}
|
||||
} else if (info_ptr->num_palette > 0) {
|
||||
palette->ncolors = info_ptr->num_palette;
|
||||
palette->ncolors = info_ptr->num_palette;
|
||||
for (i = 0; i < info_ptr->num_palette; ++i) {
|
||||
palette->colors[i].b = info_ptr->palette[i].blue;
|
||||
palette->colors[i].g = info_ptr->palette[i].green;
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#ifdef USE_SDL // {
|
||||
#ifdef USE_SDL // {
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <signal.h>
|
||||
|
@ -86,16 +86,16 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
SDL_Surface* TheScreen; /// Internal screen
|
||||
SDL_Surface* TheScreen; /// Internal screen
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
static SDL_Rect Rects[100];
|
||||
static int NumRects;
|
||||
#endif
|
||||
|
||||
static int FrameTicks; /// Frame length in ms
|
||||
static int FrameRemainder; /// Frame remainder 0.1 ms
|
||||
static int FrameFraction; /// Frame fractional term
|
||||
static int FrameTicks; /// Frame length in ms
|
||||
static int FrameRemainder; /// Frame remainder 0.1 ms
|
||||
static int FrameFraction; /// Frame fractional term
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
@ -569,18 +569,18 @@ static void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
}
|
||||
|
||||
/**
|
||||
** Wait for interactive input event for one frame.
|
||||
** Wait for interactive input event for one frame.
|
||||
**
|
||||
** Handles system events, joystick, keyboard, mouse.
|
||||
** Handles the network messages.
|
||||
** Handles the sound queue.
|
||||
** 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.
|
||||
** 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.
|
||||
** @param callbacks Call backs that handle the events.
|
||||
**
|
||||
** FIXME: the initialition could be moved out of the loop
|
||||
** FIXME: the initialition could be moved out of the loop
|
||||
*/
|
||||
void WaitEventsOneFrame(const EventCallback* callbacks)
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
}
|
||||
|
||||
ticks = SDL_GetTicks();
|
||||
if (ticks > NextFrameTicks) { // We are too slow :(
|
||||
if (ticks > NextFrameTicks) { // We are too slow :(
|
||||
#ifdef DEBUG
|
||||
// FIXME: need locking!
|
||||
// if (InterfaceState == IfaceStateNormal) {
|
||||
|
@ -622,7 +622,7 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
|
||||
for (;;) {
|
||||
//
|
||||
// Time of frame over? This makes the CPU happy. :(
|
||||
// Time of frame over? This makes the CPU happy. :(
|
||||
//
|
||||
ticks = SDL_GetTicks();
|
||||
if (!interrupts && ticks + 11 < NextFrameTicks) {
|
||||
|
@ -639,7 +639,7 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
}
|
||||
|
||||
//
|
||||
// Prepare select
|
||||
// Prepare select
|
||||
//
|
||||
maxfd = 0;
|
||||
tv.tv_sec = tv.tv_usec = 0;
|
||||
|
@ -647,7 +647,7 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
FD_ZERO(&wfds);
|
||||
|
||||
//
|
||||
// Network
|
||||
// Network
|
||||
//
|
||||
if (IsNetworkGame()) {
|
||||
if (NetworkFildes > maxfd) {
|
||||
|
@ -661,8 +661,8 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
(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
|
||||
// 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.
|
||||
|
@ -671,13 +671,13 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
i = SDL_PollEvent(event);
|
||||
#endif
|
||||
|
||||
if (i) { // Handle SDL event
|
||||
if (i) { // Handle SDL event
|
||||
SdlDoEvent(callbacks, event);
|
||||
}
|
||||
|
||||
if (s > 0) {
|
||||
//
|
||||
// Network
|
||||
// Network
|
||||
//
|
||||
if (IsNetworkGame() && FD_ISSET(NetworkFildes, &rfds) ) {
|
||||
callbacks->NetworkEvent();
|
||||
|
@ -685,7 +685,7 @@ void WaitEventsOneFrame(const EventCallback* callbacks)
|
|||
}
|
||||
|
||||
//
|
||||
// No more input and time for frame over: return
|
||||
// No more input and time for frame over: return
|
||||
//
|
||||
if (!i && s <= 0 && interrupts) {
|
||||
break;
|
||||
|
@ -778,7 +778,7 @@ void ToggleFullScreen(void)
|
|||
int ncolors;
|
||||
#endif
|
||||
|
||||
if (!TheScreen) { // don't bother if there's no surface.
|
||||
if (!TheScreen) { // don't bother if there's no surface.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -793,7 +793,7 @@ void ToggleFullScreen(void)
|
|||
framesize = w * h * TheScreen->format->BytesPerPixel;
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
if (!(pixels = malloc(framesize))) { // out of memory
|
||||
if (!(pixels = malloc(framesize))) { // out of memory
|
||||
return;
|
||||
}
|
||||
SDL_LockSurface(TheScreen);
|
||||
|
@ -819,7 +819,7 @@ void ToggleFullScreen(void)
|
|||
TheScreen = SDL_SetVideoMode(w, h, bpp, flags ^ SDL_FULLSCREEN);
|
||||
if (!TheScreen) {
|
||||
TheScreen = SDL_SetVideoMode(w, h, bpp, flags);
|
||||
if (!TheScreen) { // completely screwed.
|
||||
if (!TheScreen) { // completely screwed.
|
||||
#ifndef USE_OPENGL
|
||||
free(pixels);
|
||||
if (TheScreen->format->palette) {
|
||||
|
@ -853,8 +853,8 @@ void ToggleFullScreen(void)
|
|||
|
||||
SDL_SetClipRect(TheScreen, &clip);
|
||||
|
||||
Invalidate(); // Update display
|
||||
#else // !USE_WIN32
|
||||
Invalidate(); // Update display
|
||||
#else // !USE_WIN32
|
||||
SDL_WM_ToggleFullScreen(TheScreen);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,54 +31,54 @@
|
|||
//@{
|
||||
|
||||
/**
|
||||
** @page VideoModule Module - Video
|
||||
** @page VideoModule Module - Video
|
||||
**
|
||||
** There are lots of video functions available, therefore this
|
||||
** page tries to summarize these separately.
|
||||
** There are lots of video functions available, therefore this
|
||||
** page tries to summarize these separately.
|
||||
**
|
||||
** @note care must be taken what to use, how to use it and where
|
||||
** put new source-code. So please read the following sections
|
||||
** first.
|
||||
** @note care must be taken what to use, how to use it and where
|
||||
** put new source-code. So please read the following sections
|
||||
** first.
|
||||
**
|
||||
**
|
||||
** @section VideoMain Video main initialization
|
||||
** @section VideoMain Video main initialization
|
||||
**
|
||||
** The general setup of platform dependent video and basic video
|
||||
** functionalities is done with function @see InitVideo
|
||||
** The general setup of platform dependent video and basic video
|
||||
** functionalities is done with function @see InitVideo
|
||||
**
|
||||
** We support (depending on the platform) resolutions:
|
||||
** 640x480, 800x600, 1024x768, 1600x1200
|
||||
** with colors 8,15,16,24,32 bit
|
||||
** We support (depending on the platform) resolutions:
|
||||
** 640x480, 800x600, 1024x768, 1600x1200
|
||||
** with colors 8,15,16,24,32 bit
|
||||
**
|
||||
** @see video.h @see video.c
|
||||
** @see video.h @see video.c
|
||||
**
|
||||
**
|
||||
** @section VideoModuleHigh High Level - video dependent functions
|
||||
** @section VideoModuleHigh High Level - video dependent functions
|
||||
**
|
||||
** These are the video platforms that are supported, any platform
|
||||
** dependent settings/functionailty are located within each
|
||||
** separate files:
|
||||
** These are the video platforms that are supported, any platform
|
||||
** dependent settings/functionailty are located within each
|
||||
** separate files:
|
||||
**
|
||||
** SDL : Simple Direct Media for Linux,
|
||||
** Win32 (Windows 95/98/2000), BeOs, MacOS
|
||||
** (visit http://www.libsdl.org)
|
||||
** SDL : Simple Direct Media for Linux,
|
||||
** Win32 (Windows 95/98/2000), BeOs, MacOS
|
||||
** (visit http://www.libsdl.org)
|
||||
**
|
||||
** @see sdl.c
|
||||
** @see sdl.c
|
||||
**
|
||||
**
|
||||
** @section VideoModuleLow Low Level - draw functions
|
||||
** @section VideoModuleLow Low Level - draw functions
|
||||
**
|
||||
** All direct drawing functions
|
||||
** All direct drawing functions
|
||||
**
|
||||
** @note you might need to use Decorations (see above), to prevent
|
||||
** drawing directly to screen in conflict with the video update.
|
||||
** @note you might need to use Decorations (see above), to prevent
|
||||
** drawing directly to screen in conflict with the video update.
|
||||
**
|
||||
** @see linedraw.c
|
||||
** @see sprite.c
|
||||
** @see linedraw.c
|
||||
** @see sprite.c
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -163,7 +163,7 @@ int VideoDepth;
|
|||
SDL_Surface* TheScreen;
|
||||
|
||||
int VideoSyncSpeed = 100; /// 0 disable interrupts
|
||||
int SkipFrames; /// Skip this frames
|
||||
int SkipFrames; /// Skip this frames
|
||||
|
||||
int ColorWaterCycleStart;
|
||||
int ColorWaterCycleEnd;
|
||||
|
@ -256,7 +256,7 @@ void SetClipping(int left, int top, int right, int bottom)
|
|||
right >= VideoWidth || bottom < 0 || bottom >= VideoHeight) {
|
||||
DebugPrint("Wrong clipping %d->%d %d->%d, write cleaner code.\n" _C_
|
||||
left _C_ right _C_ top _C_ bottom);
|
||||
// Assert(0);
|
||||
// Assert(0);
|
||||
}
|
||||
#endif
|
||||
ClipRectToRect(&left, &top, &right, &bottom, 0, 0, VideoWidth, VideoHeight);
|
||||
|
|
Loading…
Reference in a new issue