NEW_VIDEO removed, should work.
This commit is contained in:
parent
d126aba8eb
commit
385387c48f
37 changed files with 1078 additions and 3960 deletions
|
@ -169,7 +169,7 @@ XIFLAGS = -I/usr/X11R6/include -I/usr/local/include \
|
|||
PROFILE= -pg
|
||||
|
||||
# Version
|
||||
VERSION= '-DVERSION="1.17pre1-build6"'
|
||||
VERSION= '-DVERSION="1.17pre1-build7"'
|
||||
|
||||
############################################################################
|
||||
# below this, nothing should be changed!
|
||||
|
@ -204,7 +204,7 @@ IFLAGS= -I$(TOPDIR)/src/include $(XIFLAGS)
|
|||
## define flags
|
||||
DEBUG= -DDEBUG #-DNEW_AI # -DFLAG_DEBUG
|
||||
DFLAGS= $(THREAD) $(CCL) $(VERSION) $(GLIB) $(VIDEO) $(ZDEFS) $(DSOUND) \
|
||||
$(DEBUG) -DNEW_UNIT -DNEW_NETWORK -DNEW_VIDEO # -DNEW_NAMES
|
||||
$(DEBUG) -DNEW_UNIT -DNEW_NETWORK -DUNIT_ON_MAP # -DNEW_NAMES
|
||||
|
||||
## choose optimise level
|
||||
#CFLAGS=-g -O0 $(PROFILE) -pipe -Wall -Werror $(IFLAGS) $(DFLAGS)
|
||||
|
|
|
@ -169,7 +169,7 @@ XIFLAGS = -I/usr/X11R6/include -I/usr/local/include \
|
|||
#PROFILE= -pg
|
||||
|
||||
# Version
|
||||
VERSION= '-DVERSION="1.17pre1-build6"'
|
||||
VERSION= '-DVERSION="1.17pre1-build7"'
|
||||
|
||||
############################################################################
|
||||
# below this, nothing should be changed!
|
||||
|
@ -204,7 +204,7 @@ IFLAGS= -I$(TOPDIR)/src/include $(XIFLAGS)
|
|||
## define flags
|
||||
DEBUG= -DDEBUG #-DNEW_AI # -DFLAG_DEBUG
|
||||
DFLAGS= $(THREAD) $(CCL) $(VERSION) $(GLIB) $(VIDEO) $(ZDEFS) $(DSOUND) \
|
||||
$(DEBUG) -DNEW_UNIT -DNEW_NETWORK -DNEW_VIDEO # -DNEW_NAMES -DNEW_FOW
|
||||
$(DEBUG) -DNEW_UNIT -DNEW_NETWORK -DUNIT_ON_MAP # -DNEW_NAMES -DNEW_FOW
|
||||
|
||||
## choose optimise level
|
||||
#CFLAGS=-g -O0 $(PROFILE) -pipe -Wall -Werror $(IFLAGS) $(DFLAGS)
|
||||
|
|
|
@ -126,7 +126,7 @@ to start.
|
|||
support and enable it (in data/ccl/sound.ccl) or and add to the line
|
||||
<P>
|
||||
DFLAGS= $(THREAD) $(GUILE) $(VERSION) $(GLIB) $(VIDEO) $(ZDEFS) $(DSOUND)
|
||||
$(DEBUG) -DNEW_VIDEO
|
||||
$(DEBUG)
|
||||
<P>
|
||||
"-DSLOW_INPUT" in Rules.make.
|
||||
|
||||
|
|
6
setup
6
setup
|
@ -23,9 +23,9 @@ cat << .. > $RULESFILE
|
|||
#------------------------------------------------------------------------------
|
||||
# HERE ARE SOME USER-CONFIGURABLE VARIABLES
|
||||
|
||||
EXTRA_CFLAGS="-DSLOW_INPUT -DNEW_UNIT -DNEW_NETWORK -DNEW_VIDEO"
|
||||
EXTRA_CFLAGS="-DSLOW_INPUT -DNEW_UNIT -DUNIT_ON_MAP -DNEW_NETWORK"
|
||||
# This could be used for experimental versions
|
||||
# -DNEW_UNIT -DNEW_NETWORK -DNEW_FOW -DNEW_NAMES -DNEW_VIDEO
|
||||
# -DNEW_UNIT -DNEW_NETWORK -DNEW_FOW -DUNIT_ON_MAP -DNEW_NAMES
|
||||
|
||||
# Compile commands
|
||||
CC=gcc
|
||||
|
@ -35,7 +35,7 @@ MAKE=make
|
|||
#------------------------------------------------------------------------------
|
||||
# DON'T CHANGE ANYTHING FROM HERE DOWN UNLESS YOU KNOW WHAT YOU ARE DOING
|
||||
|
||||
VERSION="-DVERSION=\"1.17pre1-build6\""
|
||||
VERSION="-DVERSION=\"1.17pre1-build7\""
|
||||
WIN32=-1
|
||||
|
||||
# Choose optimization level
|
||||
|
|
|
@ -56,7 +56,6 @@ local void DoActionAttackGeneric(Unit* unit,const Animation* attack)
|
|||
|
||||
flags=UnitShowAnimation(unit,attack);
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
IfDebug(
|
||||
if( (unit->Frame&127)>=VideoGraphicFrames(unit->Type->Sprite) ) {
|
||||
DebugLevel0Fn("Oops what this %s %d,%d %d #%d\n"
|
||||
|
@ -66,23 +65,8 @@ local void DoActionAttackGeneric(Unit* unit,const Animation* attack)
|
|||
,VideoGraphicFrames(unit->Type->Sprite));
|
||||
SaveUnit(unit,stdout);
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
);
|
||||
#else
|
||||
IfDebug(
|
||||
if( (unit->Frame&127)>=unit->Type->RleSprite->NumFrames ) {
|
||||
DebugLevel0Fn("Oops what this %s %d,%d %d #%d\n"
|
||||
,unit->Type->Ident
|
||||
,oframe,oframe&127
|
||||
,unit->Frame&127
|
||||
,unit->Type->RleSprite->NumFrames);
|
||||
SaveUnit(unit,stdout);
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
);
|
||||
#endif
|
||||
|
||||
if( (flags&AnimationSound) ) {
|
||||
PlayUnitSound(unit,VoiceAttacking);
|
||||
|
|
|
@ -29,7 +29,7 @@ HDRS = actions.h ai.h ccl.h freecraft.h construct.h cursor.h font.h icons.h \
|
|||
image.h interface.h map.h minimap.h missile.h pathfinder.h player.h \
|
||||
pud.h tileset.h unit.h unittype.h upgrade.h upgrade_structs.h \
|
||||
ccl_sound.h sound.h sound_id.h unitsound.h wav.h sound_server.h \
|
||||
video.h new_video.h network.h goal.h ui.h button.h menus.h \
|
||||
video.h network.h goal.h ui.h button.h menus.h \
|
||||
siod.h siodp.h iolib.h depend.h myendian.h rdtsc.h \
|
||||
etlib/generic.h etlib/xmalloc.h etlib/hash.h etlib/dllist.h
|
||||
|
||||
|
|
|
@ -9,39 +9,57 @@
|
|||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name construct.h - The constructions headerfile. */
|
||||
/*
|
||||
** (c) Copyright 1998-2000 by Lutz Sammer
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
//
|
||||
// (c) Copyright 1998-2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#ifndef __CONSTRUCT_H__
|
||||
#define __CONSTRUCT_H__
|
||||
|
||||
//@{
|
||||
|
||||
// FIXME: constructions must be configurable, referenced by indenifiers...
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- CONSTRUCTION
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct _construction_ {
|
||||
char* File[TilesetMax]; // sprite file
|
||||
#include "tileset.h"
|
||||
#include "video.h"
|
||||
|
||||
int Width; // " width
|
||||
int Height; // " height
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Constructions: shown during construction of a building.
|
||||
*/
|
||||
typedef struct _construction_ {
|
||||
char* Ident; /// construction identifier
|
||||
char* File[TilesetMax]; /// sprite file
|
||||
|
||||
int Width; /// " width
|
||||
int Height; /// " height
|
||||
|
||||
// --- FILLED UP ---
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
Graphic* Sprite; /// construction sprite image
|
||||
#else
|
||||
RleSprite* RleSprite; /// construction sprite image
|
||||
#endif
|
||||
} Construction;
|
||||
|
||||
#define ConstructionWall 15
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Macros
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#define ConstructionWall 15 /// ident nr for wall under construction
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Fucntions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Load the graphics for constructions
|
||||
extern void LoadConstructions(void);
|
||||
/// Draw a construction
|
||||
extern void DrawConstruction(int type,int image,int x,int y);
|
||||
|
||||
//@}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "player.h"
|
||||
#include "video.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Definitions
|
||||
|
@ -39,7 +40,6 @@ typedef struct _cursor_type_ CursorType;
|
|||
** private type which specifies current cursor type
|
||||
*/
|
||||
struct _cursor_type_ {
|
||||
#ifdef NEW_VIDEO
|
||||
const char* File[PlayerMaxRaces]; /// resource filename one for each race
|
||||
|
||||
// FIXME: this must be extra for each file (different sizes for the races)
|
||||
|
@ -52,20 +52,6 @@ struct _cursor_type_ {
|
|||
// --- FILLED UP ---
|
||||
|
||||
Graphic* Sprite; /// cursor sprite image
|
||||
#else
|
||||
const char* File[PlayerMaxRaces]; /// resource filename one for each race
|
||||
|
||||
// FIXME: this must be extra for each file (different sizes for the races)
|
||||
// FIXME: or must define that each image has the same size
|
||||
int HotX; /// hot point x
|
||||
int HotY; /// hot point y
|
||||
int Width; /// width of cursor
|
||||
int Height; /// height of cursor
|
||||
|
||||
// --- FILLED UP ---
|
||||
|
||||
RleSprite* RleSprite; /// cursor sprite image
|
||||
#endif
|
||||
};
|
||||
|
||||
/// cursor type (enumerated) FIXME: should remove the enumeration
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// (c) Copyright 1998-2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
#ifndef __ICONS_H__
|
||||
#define __ICONS_H__
|
||||
|
@ -66,13 +65,8 @@ extern void CleanIcons(void); /// cleanup
|
|||
extern IconId IconByIdent(const char* ident); /// name -> icon
|
||||
extern const char* IdentOfIcon(IconId icon); /// icon -> name
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/// draw icons of an unit
|
||||
extern void DrawUnitIcon(const void*,IconId,unsigned,unsigned,unsigned);
|
||||
#else
|
||||
/// draw icons of an unit
|
||||
extern void DrawUnitIcon(IconId num,unsigned flags,unsigned x,unsigned y);
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "unit.h"
|
||||
#include "new_video.h"
|
||||
#include "video.h"
|
||||
#include "tileset.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -65,11 +65,7 @@ struct _missile_type_ {
|
|||
MissileType*ImpactMissile; /// Missile produces an impact
|
||||
|
||||
// --- FILLED UP ---
|
||||
#ifdef NEW_VIDEO
|
||||
Graphic* Sprite; /// missile sprite image
|
||||
#else
|
||||
RleSprite* RleSprite; /// missile sprite image
|
||||
#endif
|
||||
};
|
||||
|
||||
/// how many missile type are maximal supported
|
||||
|
|
|
@ -1,573 +0,0 @@
|
|||
// ___________ _________ _____ __
|
||||
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
|
||||
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
|
||||
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
|
||||
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
|
||||
// \/ \/ \/ \/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name new_video.h - The video headerfile. */
|
||||
//
|
||||
// (c) Copyright 1999,2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
#ifndef __NEW_VIDEO_H__
|
||||
#define __NEW_VIDEO_H__
|
||||
|
||||
//@{
|
||||
|
||||
// Little NOTE: this should become the new video headerfile
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
typedef unsigned char VMemType8; /// 8 bpp modes pointer
|
||||
typedef unsigned short VMemType16; /// 16 bpp modes pointer
|
||||
typedef struct { char a,b,c;} VMemType24;/// 24 bpp modes pointer
|
||||
typedef unsigned long VMemType32; /// 32 bpp modes pointer
|
||||
|
||||
/**
|
||||
** General video mode pointer.
|
||||
**
|
||||
** @see VMemType8 @see VMemType16 @see VMemType24 @see VMemType32
|
||||
*/
|
||||
typedef union __vmem_type__ {
|
||||
VMemType8 D8; /// 8 bpp access
|
||||
VMemType16 D16; /// 16 bpp access
|
||||
VMemType24 D24; /// 24 bpp access
|
||||
VMemType32 D32; /// 32 bpp access
|
||||
} VMemType;
|
||||
|
||||
/// MACRO defines speed of colorcycling FIXME: should be made configurable
|
||||
#define COLOR_CYCLE_SPEED (FRAMES_PER_SECOND/4)
|
||||
|
||||
// FIXME: not quite correct for new multiple palette version
|
||||
/// System-Wide used colors.
|
||||
enum _sys_colors_ {
|
||||
ColorBlack = 0, /// use for black
|
||||
ColorDarkGreen = 149,
|
||||
ColorBlue = 206,
|
||||
ColorWhite = 246,
|
||||
ColorNPC = 247,
|
||||
ColorGray = 248,
|
||||
ColorRed = 249,
|
||||
ColorGreen = 250,
|
||||
ColorYellow = 251,
|
||||
ColorBlinkRed = 252,
|
||||
ColorViolett = 253,
|
||||
|
||||
// FIXME: this should some where made configurable
|
||||
ColorWaterCycleStart = 38, /// color # start for color cycling
|
||||
ColorWaterCycleEnd = 47, /// color # end for color cycling
|
||||
ColorIconCycleStart = 240, /// color # start for color cycling
|
||||
ColorIconCycleEnd = 244 /// color # end for color cycling
|
||||
};
|
||||
|
||||
typedef enum _sys_colors_ SysColors; /// System-Wide used colors.
|
||||
|
||||
typedef struct _palette_ Palette; /// palette typedef
|
||||
|
||||
/// Palette structure.
|
||||
struct _palette_ {
|
||||
unsigned char r; /// red component
|
||||
unsigned char g; /// green component
|
||||
unsigned char b; /// blue component
|
||||
};
|
||||
|
||||
typedef unsigned char GraphicData; /// generic graphic data type
|
||||
|
||||
/**
|
||||
** General graphic object typedef. (forward)
|
||||
*/
|
||||
typedef struct _graphic_ Graphic;
|
||||
|
||||
/**
|
||||
** General graphic object type.
|
||||
*/
|
||||
typedef struct _graphic_type_ {
|
||||
/**
|
||||
** Draw the object unclipped.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*Draw) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object unclipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawX) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object clipped to the current clipping.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawClip) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object clipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawClipX) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw part of the object unclipped.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSub) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object unclipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubX) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object clipped to the current clipping.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubClip) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object clipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubClipX)(const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
|
||||
/**
|
||||
** Draw the object unclipped and zoomed.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param z Zoom factor X 10 (10 = 1:1).
|
||||
*/
|
||||
void (*DrawZoom) (const Graphic* o,unsigned f,int x,int y,int z);
|
||||
|
||||
// FIXME: add zooming functions.
|
||||
|
||||
/*
|
||||
** Free the object.
|
||||
**
|
||||
** @param o pointer to object
|
||||
*/
|
||||
void (*Free) (Graphic* o);
|
||||
} GraphicType;
|
||||
|
||||
/**
|
||||
** General graphic object
|
||||
*/
|
||||
struct _graphic_ {
|
||||
// cache line 0
|
||||
GraphicType* Type; /// Object type dependend
|
||||
void* Frames; /// Frames of the object
|
||||
void* Pixels; /// Pointer to local or global palette
|
||||
unsigned Width; /// Width of the object
|
||||
// cache line 1
|
||||
unsigned Height; /// Height of the object
|
||||
unsigned NumFrames; /// Number of frames
|
||||
unsigned Size; /// Size of frames
|
||||
Palette* Palette; /// Loaded Palette
|
||||
// cache line 2
|
||||
//void* Offsets; /// Offsets into frames
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Wanted videomode, fullscreen or windowed.
|
||||
*/
|
||||
extern char VideoFullScreen;
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by InitVideoXXX, if 0.
|
||||
** (8,15,16,24,32)
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see main
|
||||
*/
|
||||
extern int VideoDepth;
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/**
|
||||
** Architecture-dependant videomemory. Set by InitVideoXXX.
|
||||
** FIXME: need a new function to set it, see #ifdef SDL code
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see VMemType
|
||||
*/
|
||||
extern VMemType* VideoMemory;
|
||||
|
||||
#define VideoMemory8 (&VideoMemory->D8) /// video memory 8bpp
|
||||
#define VideoMemory16 (&VideoMemory->D16) /// video memory 16bpp
|
||||
#define VideoMemory24 (&VideoMemory->D24) /// video memory 24bpp
|
||||
#define VideoMemory32 (&VideoMemory->D32) /// video memory 32bpp
|
||||
|
||||
/**
|
||||
** Architecture-dependant system palette. Applies as conversion between
|
||||
** GlobalPalette colors and their representation in videomemory.
|
||||
** Set by VideoCreatePalette or VideoSetPalette.
|
||||
** @see VideoCreatePalette @VideoSetPalette
|
||||
*/
|
||||
extern VMemType* Pixels;
|
||||
|
||||
#define Pixels8 (&Pixels->D8) /// global pixels 8bpp
|
||||
#define Pixels16 (&Pixels->D16) /// global pixels 16bpp
|
||||
#define Pixels24 (&Pixels->D24) /// global pixels 24bpp
|
||||
#define Pixels32 (&Pixels->D32) /// global pixels 32bpp
|
||||
|
||||
#endif
|
||||
|
||||
/// Loaded system palette. 256-entries long, active system palette.
|
||||
extern Palette GlobalPalette[256];
|
||||
|
||||
/**
|
||||
** Video synchronization speed. Synchronization time in prozent.
|
||||
** If =0, video framerate is not synchronized. 100 is exact
|
||||
** FRAMES_PER_SECOND (30). Game will try to redraw screen within
|
||||
** intervals of VideoSyncSpeed, not more, not less.
|
||||
** @see FRAMES_PER_SECOND @see VideoInterrupts
|
||||
*/
|
||||
extern int VideoSyncSpeed;
|
||||
|
||||
/**
|
||||
** Counter. Counts how many video interrupts occured, while proceed event
|
||||
** queue. If <1 simply do nothing, =1 means that we should redraw screen.
|
||||
** >1 means that framerate is too slow.
|
||||
** @see CheckVideoInterrupts @VideoSyncSpeed
|
||||
*/
|
||||
extern volatile int VideoInterrupts;
|
||||
|
||||
/**
|
||||
** Draw pixel unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
extern void (*VideoDrawPixel)(SysColors color,int x,int y);
|
||||
|
||||
/**
|
||||
** Draw pixel clipped to current clip setting.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
extern void (*VideoDrawPixelClip)(SysColors color,int x,int y);
|
||||
|
||||
/**
|
||||
** Draw vertical line unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
extern void (*VideoDrawVLine)(SysColors color,int x,int y
|
||||
,unsigned height);
|
||||
|
||||
/**
|
||||
** Draw vertical line clipped to current clip setting
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
extern void (*VideoDrawVLineClip)(SysColors color,int x,int y
|
||||
,unsigned height);
|
||||
|
||||
/**
|
||||
** Draw horizontal line unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
extern void (*VideoDrawHLine)(SysColors color,int x,int y
|
||||
,unsigned width);
|
||||
|
||||
/**
|
||||
** Draw horizontal line clipped to current clip setting
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
extern void (*VideoDrawHLineClip)(SysColors color,int x,int y
|
||||
,unsigned width);
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/// Does ColorCycling..
|
||||
extern void (*ColorCycle)(void);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Macros
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Get the width of a single frame of a graphic object
|
||||
#define VideoGraphicWidth(o) ((o)->Width)
|
||||
/// Get the height of a single frame of a graphic object
|
||||
#define VideoGraphicHeight(o) ((o)->Height)
|
||||
/// Get the number of frames of a graphic object
|
||||
#define VideoGraphicFrames(o) ((o)->NumFrames)
|
||||
|
||||
/// Draw a graphic object unclipped.
|
||||
#define VideoDraw(o,f,x,y) ((o)->Type->Draw)((o),(f),(x),(y))
|
||||
/// Draw a graphic object unclipped and flipped in X direction.
|
||||
#define VideoDrawX(o,f,x,y) ((o)->Type->DrawX)((o),(f),(x),(y))
|
||||
/// Draw a graphic object clipped to the current clipping.
|
||||
#define VideoDrawClip(o,f,x,y) ((o)->Type->DrawClip)((o),(f),(x),(y))
|
||||
/// Draw a graphic object clipped and flipped in X direction.
|
||||
#define VideoDrawClipX(o,f,x,y) ((o)->Type->DrawClipX)((o),(f),(x),(y))
|
||||
|
||||
/// Draw a part of graphic object unclipped.
|
||||
#define VideoDrawSub(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSub)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object unclipped and flipped in X direction.
|
||||
#define VideoDrawSubX(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubX)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object clipped to the current clipping.
|
||||
#define VideoDrawSubClip(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubClip)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object clipped and flipped in X direction.
|
||||
#define VideoDrawSubClipX(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubClipX)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
|
||||
/// Draw a graphic object zoomed unclipped.
|
||||
#define VideoDrawZoom(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoom)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed unclipped flipped in X direction.
|
||||
#define VideoDrawZoomX(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomX)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed clipped to the current clipping.
|
||||
#define VideoDrawZoomClip(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomClip)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed clipped and flipped in X direction.
|
||||
#define VideoDrawZoomClipX(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomClipX)((o),(f),(x),(y),(z))
|
||||
|
||||
/// Draw a part of graphic object zoomed unclipped.
|
||||
#define VideoDrawZoomSub(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSub)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed unclipped flipped in X direction.
|
||||
#define VideoDrawZoomSubX(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubX)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed clipped to the current clipping.
|
||||
#define VideoDrawZoomSubClip(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubClip)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed clipped flipped in X direction.
|
||||
#define VideoDrawZoomSubClipX(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubClipX)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
|
||||
/// Free a graphic object.
|
||||
#define VideoFree(o) ((o)->Type->Free)((o))
|
||||
/// Save (NULL) free a graphic object.
|
||||
#define VideoSaveFree(o) \
|
||||
do { if( (o) ) ((o)->Type->Free)((o)); } while( 0 )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// initialize the video part
|
||||
extern void InitVideo(void);
|
||||
|
||||
/**
|
||||
** Invalidates selected area on window or screen. Use for accurate
|
||||
** redrawing. in so
|
||||
** @param x x screen coordinate
|
||||
** @param y y screen coordinate
|
||||
** @param w width in pixel
|
||||
** @param h height in pixel
|
||||
*/
|
||||
extern void InvalidateArea(int x,int y,int w,int h);
|
||||
|
||||
/// Simply invalidates whole window or screen.
|
||||
extern void Invalidate(void);
|
||||
|
||||
/**
|
||||
** Realize videomemory. X11 implemenataion just does XFlush.
|
||||
** SVGALIB without linear addressing should use this.
|
||||
*/
|
||||
extern void RealizeVideoMemory(void);
|
||||
|
||||
/**
|
||||
** Process all system events. This function also keeps synchronization
|
||||
** of game.
|
||||
*/
|
||||
extern void WaitEventsAndKeepSync(void);
|
||||
|
||||
/// Load graphic from PNG file.
|
||||
extern Graphic* LoadGraphicPNG(const char* name);
|
||||
|
||||
/// New graphic
|
||||
extern Graphic* NewGraphic(unsigned d,unsigned w,unsigned h);
|
||||
|
||||
/// Make graphic
|
||||
extern Graphic* MakeGraphic(unsigned,unsigned,unsigned,void*,unsigned);
|
||||
|
||||
/// Load graphic
|
||||
extern Graphic* LoadGraphic(const char* file);
|
||||
|
||||
/// Load sprite
|
||||
extern Graphic* LoadSprite(const char* file,unsigned w,unsigned h);
|
||||
|
||||
/// Init graphic
|
||||
extern void InitGraphic(void);
|
||||
|
||||
/// Init sprite
|
||||
extern void InitSprite(void);
|
||||
|
||||
/// Init line draw
|
||||
extern void InitLineDraw(void);
|
||||
|
||||
/// Draw rectangle.
|
||||
extern void VideoDrawRectangle(SysColors color,int x,int y
|
||||
,unsigned w,unsigned h);
|
||||
|
||||
/// Fill rectangle.
|
||||
extern void VideoFillRectangle(SysColors color,int x,int y
|
||||
,unsigned w,unsigned h);
|
||||
|
||||
/**
|
||||
** Set clipping for nearly all vector primitives. Functions which support
|
||||
** clipping will be marked Clip. Set the system-wide clipping rectangle.
|
||||
**
|
||||
** @param left Left x coordinate
|
||||
** @param top Top y coordinate
|
||||
** @param right Right x coordinate
|
||||
** @param bottom Bottom y coordinate
|
||||
*/
|
||||
extern void SetClipping(int left,int top,int right,int bottom);
|
||||
|
||||
/**
|
||||
** Push current clipping.
|
||||
*/
|
||||
extern void PushClipping(void);
|
||||
|
||||
/**
|
||||
** Pop current clipping.
|
||||
*/
|
||||
extern void PopClipping(void);
|
||||
|
||||
/**
|
||||
** Load a picture and display it on the screen (full screen),
|
||||
** changing the colormap and so on..
|
||||
**
|
||||
** @param name name of the picture (file) to display
|
||||
*/
|
||||
extern void DisplayPicture(const char *name);
|
||||
|
||||
/**
|
||||
** Load palette from resource. Just loads palette, to set it use
|
||||
** VideoCreatePalette, which sets system palette.
|
||||
**
|
||||
** @param pal buffer to store palette (256-entries long)
|
||||
** @param name resource file name
|
||||
**
|
||||
** @see VideoCreatePalette
|
||||
*/
|
||||
extern void LoadRGB(Palette* pal,const char* name);
|
||||
|
||||
/**
|
||||
** Creates a hardware palette from an independend Palette struct.
|
||||
**
|
||||
** @param palette System independ palette structure.
|
||||
**
|
||||
** @returns A palette in hardware dependend format.
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
extern VMemType* VideoCreateNewPalette(const Palette* palette);
|
||||
|
||||
/**
|
||||
** Initialize Pixels[] for all players.
|
||||
** (bring Players[] in sync with Pixels[])
|
||||
**
|
||||
** @see VideoSetPalette
|
||||
*/
|
||||
extern void SetPlayersPalette(void);
|
||||
|
||||
/**
|
||||
** Initializes system palette. Also calls SetPlayersPalette to set
|
||||
** palette for all players.
|
||||
**
|
||||
** @param palette VMemType structure, as created by VideoCreateNewPalette
|
||||
** @see SetPlayersPalette
|
||||
*/
|
||||
extern void VideoSetPalette(const VMemType* palette);
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Set the system hardware palette from an independend Palette struct.
|
||||
**
|
||||
** @param palette System independ palette structure.
|
||||
*/
|
||||
extern void VideoCreatePalette(const Palette* palette);
|
||||
|
||||
/// Initializes video synchronization.
|
||||
extern void SetVideoSync(void);
|
||||
|
||||
/// Prints warning if video is too slow..
|
||||
extern void CheckVideoInterrupts(void);
|
||||
|
||||
/// Toggle mouse grab mode
|
||||
extern void ToggleGrabMouse(void);
|
||||
|
||||
//@}
|
||||
|
||||
#endif // !__NEW_VIDEO_H__
|
|
@ -9,11 +9,10 @@
|
|||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name player.h - The player headerfile. */
|
||||
/*
|
||||
** (c) Copyright 1998-2000 by Lutz Sammer
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
//
|
||||
// (c) Copyright 1998-2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#ifndef __PLAYER_H__
|
||||
#define __PLAYER_H__
|
||||
|
@ -32,6 +31,7 @@ typedef struct _player_ Player;
|
|||
#include "upgrade_structs.h"
|
||||
#include "unittype.h"
|
||||
#include "unit.h"
|
||||
#include "video.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Player type
|
||||
|
@ -59,6 +59,7 @@ struct _player_ {
|
|||
unsigned Resources[MaxCosts]; /// resources in store
|
||||
int Incomes[MaxCosts]; /// income of the resources.
|
||||
|
||||
// FIXME: needed again? if not remove
|
||||
// unsigned UnitFlags[
|
||||
// (UnitTypeInternalMax+BitsOf(unsigned)-1)
|
||||
// /BitsOf(unsigned)]; /// flags what units are available
|
||||
|
@ -79,7 +80,6 @@ struct _player_ {
|
|||
// Display video
|
||||
unsigned Color; /// color of units on minimap
|
||||
|
||||
// FIXME: not used
|
||||
union {
|
||||
struct __4pixel8__ {
|
||||
VMemType8 Pixels[4]; /// palette colors #0 ... #3
|
||||
|
@ -95,14 +95,7 @@ struct _player_ {
|
|||
} Depth32; /// player colors for 32bpp
|
||||
} UnitColors; /// Unit colors for faster setup
|
||||
|
||||
// FIXME: this should be removed, use UnitColors insteed
|
||||
//unsigned UnitColor1; /// Unit color 1 on map and icons
|
||||
//unsigned UnitColor2; /// Unit color 2 on map and icons
|
||||
//unsigned UnitColor3; /// Unit color 3 on map and icons
|
||||
//unsigned UnitColor4; /// Unit color 4 on map and icons
|
||||
|
||||
// Upgrades/Allows:
|
||||
|
||||
Allow Allow; /// Allowed for player
|
||||
UpgradeTimers UTimers; /// Timer for the upgrades
|
||||
};
|
||||
|
@ -189,26 +182,18 @@ extern int HaveUnitTypeByType(const Player* player,const UnitType* type);
|
|||
/// Has the player units of that type
|
||||
extern int HaveUnitTypeByIdent(const Player* player,const char* ident);
|
||||
|
||||
/// FIXME: write short docu
|
||||
/// Initialize the computer opponent AI
|
||||
extern void PlayersInitAi(void);
|
||||
/// FIXME: write short docu
|
||||
/// Called each frame for player handlers (AI)
|
||||
extern void PlayersEachFrame(void);
|
||||
/// FIXME: write short docu
|
||||
/// Called each second for player handlers (AI)
|
||||
extern void PlayersEachSecond(void);
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/// Change current color set to new player.
|
||||
extern void PlayerPixels(const Player* player);
|
||||
|
||||
/// Change current color set to new player of the sprite
|
||||
extern void GraphicPlayerPixels(const Player* player, const Graphic * sprite);
|
||||
#else
|
||||
/// Change current color set to new player.
|
||||
extern void PlayerPixels(const Player* player);
|
||||
|
||||
/// Change current color set to new player of the sprite
|
||||
extern void RLEPlayerPixels(const Player* player, const RleSprite * sprite);
|
||||
#endif
|
||||
|
||||
/// Output debug informations for players
|
||||
extern void DebugPlayers(void);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "new_video.h"
|
||||
#include "video.h"
|
||||
#include "upgrade_structs.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -195,11 +195,7 @@ struct _unit_type_ {
|
|||
|
||||
void* Property; /// CCL property storage
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
Graphic* Sprite; /// sprite images
|
||||
#else
|
||||
RleSprite* RleSprite; /// sprite images
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Who many unit types are currently supported.
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name video.h - The video headerfile. */
|
||||
/*
|
||||
** (c) Copyright 1998-2000 by Lutz Sammer
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
//
|
||||
// (c) Copyright 1999,2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
#ifndef __VIDEO_H__
|
||||
#define __VIDEO_H__
|
||||
|
@ -24,219 +24,541 @@
|
|||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "new_video.h"
|
||||
|
||||
#ifndef NEW_VIDEO // { Should be removed with new video final version
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// MACRO defines speed of colorcycling
|
||||
typedef unsigned char VMemType8; /// 8 bpp modes pointer
|
||||
typedef unsigned short VMemType16; /// 16 bpp modes pointer
|
||||
typedef struct { char a,b,c;} VMemType24;/// 24 bpp modes pointer
|
||||
typedef unsigned long VMemType32; /// 32 bpp modes pointer
|
||||
|
||||
/**
|
||||
** General video mode pointer.
|
||||
**
|
||||
** @see VMemType8 @see VMemType16 @see VMemType24 @see VMemType32
|
||||
*/
|
||||
typedef union __vmem_type__ {
|
||||
VMemType8 D8; /// 8 bpp access
|
||||
VMemType16 D16; /// 16 bpp access
|
||||
VMemType24 D24; /// 24 bpp access
|
||||
VMemType32 D32; /// 32 bpp access
|
||||
} VMemType;
|
||||
|
||||
/// MACRO defines speed of colorcycling FIXME: should be made configurable
|
||||
#define COLOR_CYCLE_SPEED (FRAMES_PER_SECOND/4)
|
||||
|
||||
// FIXME: not quite correct for new multiple palette version
|
||||
/// System-Wide used colors.
|
||||
enum _sys_colors_ {
|
||||
ColorBlack = 0, /// use for black
|
||||
ColorDarkGreen = 149,
|
||||
ColorBlue = 206,
|
||||
ColorWhite = 246,
|
||||
ColorNPC = 247,
|
||||
ColorGray = 248,
|
||||
ColorRed = 249,
|
||||
ColorGreen = 250,
|
||||
ColorYellow = 251,
|
||||
ColorBlinkRed = 252,
|
||||
ColorViolett = 253,
|
||||
|
||||
/**@name RleSprite */
|
||||
//@{
|
||||
|
||||
/** RleSprite structure. Transparent, single frame, not packed image.
|
||||
Fast enough. Primarily used for fonts. color 255 is transparent.
|
||||
@see LoadRleSprite
|
||||
@see DrawRleSprite
|
||||
@see DrawRleSpriteClipped
|
||||
@see DrawRleSpriteClippedX
|
||||
@see DrawRleSpriteX
|
||||
@see FreeRleSprite
|
||||
*/
|
||||
struct RleSprite {
|
||||
unsigned Width; /// width of a frame
|
||||
unsigned Height; /// height of a frame
|
||||
GraphicData* Pixels; /// pointer to local or global palette
|
||||
int NumFrames; /// number of frames
|
||||
IfDebug( int ByteSize; )
|
||||
/**
|
||||
** pointer to the frames. frames are bitmaps converted via global
|
||||
** Pixels[] structure or local object Pixels (if local Pixels != 0).
|
||||
*/
|
||||
unsigned char* Frames[0];
|
||||
// FIXME: this should some where made configurable
|
||||
ColorWaterCycleStart = 38, /// color # start for color cycling
|
||||
ColorWaterCycleEnd = 47, /// color # end for color cycling
|
||||
ColorIconCycleStart = 240, /// color # start for color cycling
|
||||
ColorIconCycleEnd = 244 /// color # end for color cycling
|
||||
};
|
||||
|
||||
typedef struct RleSprite RleSprite;
|
||||
typedef enum _sys_colors_ SysColors; /// System-Wide used colors.
|
||||
|
||||
/** Load RLE Sprite. new memory block is allocated.
|
||||
@param name resource file name
|
||||
@param w width of a frame
|
||||
@param h height of a frame
|
||||
*/
|
||||
extern RleSprite* LoadRleSprite(const char* name,unsigned w,unsigned h);
|
||||
typedef struct _palette_ Palette; /// palette typedef
|
||||
|
||||
/** Draw RLE Sprite..
|
||||
@param sprite pointer to RLE Sprite OBJECT
|
||||
@param frame number of frame
|
||||
@param x x coordinate on the screen
|
||||
@param y y coordinate on the screen
|
||||
*/
|
||||
extern void DrawRleSprite(RleSprite* sprite,unsigned frame,int x,int y);
|
||||
/// Palette structure.
|
||||
struct _palette_ {
|
||||
unsigned char r; /// red component
|
||||
unsigned char g; /// green component
|
||||
unsigned char b; /// blue component
|
||||
};
|
||||
|
||||
/** Draw RLE Sprite FLIPPED X..
|
||||
@param sprite pointer to RLE Sprite OBJECT
|
||||
@param frame number of frame
|
||||
@param x x coordinate on the screen
|
||||
@param y y coordinate on the screen
|
||||
*/
|
||||
extern void DrawRleSpriteX(RleSprite* sprite,unsigned frame,int x,int y);
|
||||
typedef unsigned char GraphicData; /// generic graphic data type
|
||||
|
||||
/** Draw RLE Sprite CLIPPED..
|
||||
@param sprite pointer to RLE Sprite OBJECT
|
||||
@param frame number of frame
|
||||
@param x x coordinate on the screen
|
||||
@param y y coordinate on the screen
|
||||
*/
|
||||
extern void DrawRleSpriteClipped(RleSprite* sprite,unsigned frame,int x,int y);
|
||||
|
||||
/** Draw RLE Sprite CLIPPED FLIPPED X..
|
||||
@param sprite pointer to RLE Sprite OBJECT
|
||||
@param frame number of frame
|
||||
@param x x coordinate on the screen
|
||||
@param y y coordinate on the screen
|
||||
*/
|
||||
extern void DrawRleSpriteClippedX(RleSprite* sprite,unsigned frame,int x,int y);
|
||||
|
||||
/** Free pointer returned by LoadRleSprite. Dereferencing pointer is no longer
|
||||
correct.
|
||||
@param sprite pointer returned by LoadRleSprite
|
||||
*/
|
||||
extern void FreeRleSprite(RleSprite *sprite);
|
||||
//@}
|
||||
|
||||
|
||||
/** Set clipping for nearly all vector primitives. Functions which support
|
||||
clipping will be marked CLIPPED. Set system-wide clipping rectangle.
|
||||
@param left left x coordinate
|
||||
@param top top y coordinate
|
||||
@param right right x coordinate
|
||||
@param bottom bottom y coordinate
|
||||
*/
|
||||
extern void SetClipping(int left,int top,int right,int bottom);
|
||||
|
||||
|
||||
/** Architecture-dependant videomemory. Set by InitVideoXXX.
|
||||
@see InitVideo
|
||||
@see InitVideoX11
|
||||
@see InitVideoSVGA
|
||||
@see InitVideoSdl
|
||||
@see InitVideoWin32
|
||||
*/
|
||||
extern void* VideoMemory;
|
||||
|
||||
/** Architecture-dependant video depth. Set by InitVideoXXX.
|
||||
@see InitVideo
|
||||
@see InitVideoX11
|
||||
@see InitVideoSVGA
|
||||
@see InitVideoSdl
|
||||
@see InitVideoWin32
|
||||
/**
|
||||
** General graphic object typedef. (forward)
|
||||
*/
|
||||
typedef struct _graphic_ Graphic;
|
||||
|
||||
/**
|
||||
** General graphic object type.
|
||||
*/
|
||||
typedef struct _graphic_type_ {
|
||||
/**
|
||||
** Draw the object unclipped.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*Draw) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object unclipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawX) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object clipped to the current clipping.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawClip) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw the object clipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawClipX) (const Graphic* o,unsigned f,int x,int y);
|
||||
/**
|
||||
** Draw part of the object unclipped.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSub) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object unclipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubX) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object clipped to the current clipping.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubClip) (const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
/**
|
||||
** Draw part of the object clipped and flipped in X direction.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
void (*DrawSubClipX)(const Graphic* o,int gx,int gy
|
||||
,unsigned w,unsigned h,int x,int y);
|
||||
|
||||
/**
|
||||
** Draw the object unclipped and zoomed.
|
||||
**
|
||||
** @param o pointer to object
|
||||
** @param f number of frame (object index)
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param z Zoom factor X 10 (10 = 1:1).
|
||||
*/
|
||||
void (*DrawZoom) (const Graphic* o,unsigned f,int x,int y,int z);
|
||||
|
||||
// FIXME: add zooming functions.
|
||||
|
||||
/*
|
||||
** Free the object.
|
||||
**
|
||||
** @param o pointer to object
|
||||
*/
|
||||
void (*Free) (Graphic* o);
|
||||
} GraphicType;
|
||||
|
||||
/**
|
||||
** General graphic object
|
||||
*/
|
||||
struct _graphic_ {
|
||||
// cache line 0
|
||||
GraphicType* Type; /// Object type dependend
|
||||
void* Frames; /// Frames of the object
|
||||
void* Pixels; /// Pointer to local or global palette
|
||||
unsigned Width; /// Width of the object
|
||||
// cache line 1
|
||||
unsigned Height; /// Height of the object
|
||||
unsigned NumFrames; /// Number of frames
|
||||
unsigned Size; /// Size of frames
|
||||
Palette* Palette; /// Loaded Palette
|
||||
// cache line 2
|
||||
//void* Offsets; /// Offsets into frames
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Wanted videomode, fullscreen or windowed.
|
||||
*/
|
||||
extern char VideoFullScreen;
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by InitVideoXXX, if 0.
|
||||
** (8,15,16,24,32)
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see main
|
||||
*/
|
||||
extern int VideoDepth;
|
||||
/// Sub depth 555, 565
|
||||
//extern int VideoSubDepth;
|
||||
|
||||
/// 32 bpp modes video memory address
|
||||
#define VideoMemory32 ((VMemType32*)VideoMemory)
|
||||
/// 24 bpp modes video memory address
|
||||
#define VideoMemory24 ((VMemType24*)VideoMemory)
|
||||
/// 16 bpp modes video memory address
|
||||
#define VideoMemory16 ((VMemType16*)VideoMemory)
|
||||
/// 8 bpp modes video memory address
|
||||
#define VideoMemory8 ((VMemType8*)VideoMemory)
|
||||
/**
|
||||
** Architecture-dependant videomemory. Set by InitVideoXXX.
|
||||
** FIXME: need a new function to set it, see #ifdef SDL code
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see VMemType
|
||||
*/
|
||||
extern VMemType* VideoMemory;
|
||||
|
||||
/** Architecture-dependant system palette. Applies as conversion between
|
||||
GlobalPalette colors and their representation in videomemory. Set by
|
||||
VideoCreatePalette.
|
||||
@see VideoCreatePalette
|
||||
*/
|
||||
extern VMemType8 * Pixels8; /// 8 bpp
|
||||
extern VMemType16 * Pixels16; /// 16 bpp
|
||||
extern VMemType24 * Pixels24; /// 24 bpp
|
||||
extern VMemType32 * Pixels32; /// 32 bpp
|
||||
#define VideoMemory8 (&VideoMemory->D8) /// video memory 8bpp
|
||||
#define VideoMemory16 (&VideoMemory->D16) /// video memory 16bpp
|
||||
#define VideoMemory24 (&VideoMemory->D24) /// video memory 24bpp
|
||||
#define VideoMemory32 (&VideoMemory->D32) /// video memory 32bpp
|
||||
|
||||
/** Set videomode. Tries to set choosen videomode. Only 640x480, 800x600
|
||||
and 1024x768 are available. If videoadapter is not good enough module will
|
||||
return failure. Default mode is 640x480.
|
||||
@return 1 if videomode set correctly; 0 otherwise. */
|
||||
extern int SetVideoMode(int width);
|
||||
/**
|
||||
** Architecture-dependant system palette. Applies as conversion between
|
||||
** GlobalPalette colors and their representation in videomemory.
|
||||
** Set by VideoCreatePalette or VideoSetPalette.
|
||||
** @see VideoCreatePalette @VideoSetPalette
|
||||
*/
|
||||
extern VMemType* Pixels;
|
||||
|
||||
/// Initialize Pixels[] for all players (bring Players[] in sync with Pixels[])
|
||||
extern void SetPlayersPalette(void);
|
||||
#define Pixels8 (&Pixels->D8) /// global pixels 8bpp
|
||||
#define Pixels16 (&Pixels->D16) /// global pixels 16bpp
|
||||
#define Pixels24 (&Pixels->D24) /// global pixels 24bpp
|
||||
#define Pixels32 (&Pixels->D32) /// global pixels 32bpp
|
||||
|
||||
/**@name Architecture-dependant video functions */
|
||||
//@{
|
||||
/// Loaded system palette. 256-entries long, active system palette.
|
||||
extern Palette GlobalPalette[256];
|
||||
|
||||
/// Initializes video synchronization..
|
||||
extern void SetVideoSync(void);
|
||||
/**
|
||||
** Video synchronization speed. Synchronization time in prozent.
|
||||
** If =0, video framerate is not synchronized. 100 is exact
|
||||
** FRAMES_PER_SECOND (30). Game will try to redraw screen within
|
||||
** intervals of VideoSyncSpeed, not more, not less.
|
||||
** @see FRAMES_PER_SECOND @see VideoInterrupts
|
||||
*/
|
||||
extern int VideoSyncSpeed;
|
||||
|
||||
/// Prints warning if video is too slow..
|
||||
extern void CheckVideoInterrupts(void);
|
||||
/**
|
||||
** Counter. Counts how many video interrupts occured, while proceed event
|
||||
** queue. If <1 simply do nothing, =1 means that we should redraw screen.
|
||||
** >1 means that framerate is too slow.
|
||||
** @see CheckVideoInterrupts @VideoSyncSpeed
|
||||
*/
|
||||
extern volatile int VideoInterrupts;
|
||||
|
||||
/// Does ColorCycling..
|
||||
extern void ColorCycle(void);
|
||||
/**
|
||||
** Draw pixel unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
extern void (*VideoDrawPixel)(SysColors color,int x,int y);
|
||||
|
||||
/** Creates a palette from a Palette struct */
|
||||
extern GraphicData * VideoCreateNewPalette(const Palette *palette);
|
||||
/**
|
||||
** Draw pixel clipped to current clip setting.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
extern void (*VideoDrawPixelClip)(SysColors color,int x,int y);
|
||||
|
||||
/** Initializes system palette. Also calls SetPlayersPalette to set palette for
|
||||
all players.
|
||||
@param palette GraphicData structure, as created by VideoCreateNewPalette
|
||||
@see SetPlayersPalette
|
||||
*/
|
||||
extern void VideoSetPalette(const GraphicData *palette);
|
||||
/**
|
||||
** Draw vertical line unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
extern void (*VideoDrawVLine)(SysColors color,int x,int y
|
||||
,unsigned height);
|
||||
|
||||
/// OBSOLETE: Calls VideoCreateNewPalette with the palette argument, and then
|
||||
/// feeds the result to VideoSetPalette to initialize system palette with it.
|
||||
extern void VideoCreatePalette(const Palette *palette);
|
||||
/**
|
||||
** Draw vertical line clipped to current clip setting
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
extern void (*VideoDrawVLineClip)(SysColors color,int x,int y
|
||||
,unsigned height);
|
||||
|
||||
/// Process all system events. This function also keeps synchronization of game.
|
||||
extern void WaitEventsAndKeepSync(void);
|
||||
/**
|
||||
** Draw horizontal line unclipped.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
extern void (*VideoDrawHLine)(SysColors color,int x,int y
|
||||
,unsigned width);
|
||||
|
||||
/** Realize videomemory. X11 implemenataion just does XFlush. SVGALIB without
|
||||
linear addressing should use this. */
|
||||
extern void RealizeVideoMemory(void);
|
||||
/**
|
||||
** Draw horizontal line clipped to current clip setting
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
extern void (*VideoDrawHLineClip)(SysColors color,int x,int y
|
||||
,unsigned width);
|
||||
|
||||
/// Initialize video hardware..
|
||||
extern void GameInitDisplay(void);
|
||||
/// Does ColorCycling..
|
||||
extern void (*ColorCycle)(void);
|
||||
|
||||
/** Invalidates selected area on window or screen. Use for accurate redrawing.
|
||||
in so
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param w width
|
||||
@param h height
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Macros
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Get the width of a single frame of a graphic object
|
||||
#define VideoGraphicWidth(o) ((o)->Width)
|
||||
/// Get the height of a single frame of a graphic object
|
||||
#define VideoGraphicHeight(o) ((o)->Height)
|
||||
/// Get the number of frames of a graphic object
|
||||
#define VideoGraphicFrames(o) ((o)->NumFrames)
|
||||
|
||||
/// Draw a graphic object unclipped.
|
||||
#define VideoDraw(o,f,x,y) ((o)->Type->Draw)((o),(f),(x),(y))
|
||||
/// Draw a graphic object unclipped and flipped in X direction.
|
||||
#define VideoDrawX(o,f,x,y) ((o)->Type->DrawX)((o),(f),(x),(y))
|
||||
/// Draw a graphic object clipped to the current clipping.
|
||||
#define VideoDrawClip(o,f,x,y) ((o)->Type->DrawClip)((o),(f),(x),(y))
|
||||
/// Draw a graphic object clipped and flipped in X direction.
|
||||
#define VideoDrawClipX(o,f,x,y) ((o)->Type->DrawClipX)((o),(f),(x),(y))
|
||||
|
||||
/// Draw a part of graphic object unclipped.
|
||||
#define VideoDrawSub(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSub)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object unclipped and flipped in X direction.
|
||||
#define VideoDrawSubX(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubX)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object clipped to the current clipping.
|
||||
#define VideoDrawSubClip(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubClip)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
/// Draw a part of graphic object clipped and flipped in X direction.
|
||||
#define VideoDrawSubClipX(o,ix,iy,w,h,x,y) \
|
||||
((o)->Type->DrawSubClipX)((o),(ix),(iy),(w),(h),(x),(y))
|
||||
|
||||
/// Draw a graphic object zoomed unclipped.
|
||||
#define VideoDrawZoom(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoom)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed unclipped flipped in X direction.
|
||||
#define VideoDrawZoomX(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomX)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed clipped to the current clipping.
|
||||
#define VideoDrawZoomClip(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomClip)((o),(f),(x),(y),(z))
|
||||
/// Draw a graphic object zoomed clipped and flipped in X direction.
|
||||
#define VideoDrawZoomClipX(o,f,x,y,z) \
|
||||
((o)->Type->DrawZoomClipX)((o),(f),(x),(y),(z))
|
||||
|
||||
/// Draw a part of graphic object zoomed unclipped.
|
||||
#define VideoDrawZoomSub(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSub)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed unclipped flipped in X direction.
|
||||
#define VideoDrawZoomSubX(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubX)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed clipped to the current clipping.
|
||||
#define VideoDrawZoomSubClip(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubClip)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
/// Draw a part of graphic object zoomed clipped flipped in X direction.
|
||||
#define VideoDrawZoomSubClipX(o,ix,iy,w,h,x,y,z) \
|
||||
((o)->Type->DrawZoomSubClipX)((o),(ix),(iy),(w),(h),(x),(y),(z))
|
||||
|
||||
/// Free a graphic object.
|
||||
#define VideoFree(o) ((o)->Type->Free)((o))
|
||||
/// Save (NULL) free a graphic object.
|
||||
#define VideoSaveFree(o) \
|
||||
do { if( (o) ) ((o)->Type->Free)((o)); } while( 0 )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// initialize the video part
|
||||
extern void InitVideo(void);
|
||||
|
||||
/**
|
||||
** Invalidates selected area on window or screen. Use for accurate
|
||||
** redrawing. in so
|
||||
** @param x x screen coordinate
|
||||
** @param y y screen coordinate
|
||||
** @param w width in pixel
|
||||
** @param h height in pixel
|
||||
*/
|
||||
extern void InvalidateArea(int x,int y,int w,int h);
|
||||
|
||||
/// Simply invalidates whole window or screen..
|
||||
/// Simply invalidates whole window or screen.
|
||||
extern void Invalidate(void);
|
||||
|
||||
/// Toggle mouse grab mode
|
||||
/**
|
||||
** Realize videomemory. X11 implemenataion just does XFlush.
|
||||
** SVGALIB without linear addressing should use this.
|
||||
*/
|
||||
extern void RealizeVideoMemory(void);
|
||||
|
||||
/**
|
||||
** Process all system events. This function also keeps synchronization
|
||||
** of game.
|
||||
*/
|
||||
extern void WaitEventsAndKeepSync(void);
|
||||
|
||||
/// Load graphic from PNG file.
|
||||
extern Graphic* LoadGraphicPNG(const char* name);
|
||||
|
||||
/// New graphic
|
||||
extern Graphic* NewGraphic(unsigned d,unsigned w,unsigned h);
|
||||
|
||||
/// Make graphic
|
||||
extern Graphic* MakeGraphic(unsigned,unsigned,unsigned,void*,unsigned);
|
||||
|
||||
/// Load graphic
|
||||
extern Graphic* LoadGraphic(const char* file);
|
||||
|
||||
/// Load sprite
|
||||
extern Graphic* LoadSprite(const char* file,unsigned w,unsigned h);
|
||||
|
||||
/// Init graphic
|
||||
extern void InitGraphic(void);
|
||||
|
||||
/// Init sprite
|
||||
extern void InitSprite(void);
|
||||
|
||||
/// Init line draw
|
||||
extern void InitLineDraw(void);
|
||||
|
||||
/// Draw rectangle.
|
||||
extern void VideoDrawRectangle(SysColors color,int x,int y
|
||||
,unsigned w,unsigned h);
|
||||
|
||||
/// Fill rectangle.
|
||||
extern void VideoFillRectangle(SysColors color,int x,int y
|
||||
,unsigned w,unsigned h);
|
||||
|
||||
/**
|
||||
** Set clipping for nearly all vector primitives. Functions which support
|
||||
** clipping will be marked Clip. Set the system-wide clipping rectangle.
|
||||
**
|
||||
** @param left Left x coordinate
|
||||
** @param top Top y coordinate
|
||||
** @param right Right x coordinate
|
||||
** @param bottom Bottom y coordinate
|
||||
*/
|
||||
extern void SetClipping(int left,int top,int right,int bottom);
|
||||
|
||||
/**
|
||||
** Push current clipping.
|
||||
*/
|
||||
extern void PushClipping(void);
|
||||
|
||||
/**
|
||||
** Pop current clipping.
|
||||
*/
|
||||
extern void PopClipping(void);
|
||||
|
||||
/**
|
||||
** Load a picture and display it on the screen (full screen),
|
||||
** changing the colormap and so on..
|
||||
**
|
||||
** @param name name of the picture (file) to display
|
||||
*/
|
||||
extern void DisplayPicture(const char *name);
|
||||
|
||||
/**
|
||||
** Load palette from resource. Just loads palette, to set it use
|
||||
** VideoCreatePalette, which sets system palette.
|
||||
**
|
||||
** @param pal buffer to store palette (256-entries long)
|
||||
** @param name resource file name
|
||||
**
|
||||
** @see VideoCreatePalette
|
||||
*/
|
||||
extern void LoadRGB(Palette* pal,const char* name);
|
||||
|
||||
/**
|
||||
** Creates a hardware palette from an independend Palette struct.
|
||||
**
|
||||
** @param palette System independ palette structure.
|
||||
**
|
||||
** @returns A palette in hardware dependend format.
|
||||
*/
|
||||
extern VMemType* VideoCreateNewPalette(const Palette* palette);
|
||||
|
||||
/**
|
||||
** Initialize Pixels[] for all players.
|
||||
** (bring Players[] in sync with Pixels[])
|
||||
**
|
||||
** @see VideoSetPalette
|
||||
*/
|
||||
extern void SetPlayersPalette(void);
|
||||
|
||||
/**
|
||||
** Initializes system palette. Also calls SetPlayersPalette to set
|
||||
** palette for all players.
|
||||
**
|
||||
** @param palette VMemType structure, as created by VideoCreateNewPalette
|
||||
** @see SetPlayersPalette
|
||||
*/
|
||||
extern void VideoSetPalette(const VMemType* palette);
|
||||
|
||||
/**
|
||||
** Set the system hardware palette from an independend Palette struct.
|
||||
**
|
||||
** @param palette System independ palette structure.
|
||||
*/
|
||||
extern void VideoCreatePalette(const Palette* palette);
|
||||
|
||||
/// Initializes video synchronization.
|
||||
extern void SetVideoSync(void);
|
||||
|
||||
/// Prints warning if video is too slow..
|
||||
extern void CheckVideoInterrupts(void);
|
||||
|
||||
/// Toggle mouse grab mode
|
||||
extern void ToggleGrabMouse(void);
|
||||
|
||||
//@}
|
||||
|
||||
/** Counter. Counts how many video interrupts occured, while proceed event
|
||||
queue. If <1 simply do nothing, =1 means that we should redraw screen. >1
|
||||
means that framerate is too slow.
|
||||
@see CheckVideoInterrupts
|
||||
*/
|
||||
extern volatile int VideoInterrupts;
|
||||
|
||||
/**
|
||||
** Video synchronization speed. Synchronization time in prozent.
|
||||
** If =0, video framerate is not synchronized. Game will try to redraw screen
|
||||
** within intervals of VideoSyncSpeed, not more, not less
|
||||
*/
|
||||
extern int VideoSyncSpeed;
|
||||
|
||||
#endif // } !NEW_VIDEO
|
||||
|
||||
//@}
|
||||
|
||||
#endif // !__VIDEO_H__
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name construct.c - The constructions. */
|
||||
/*
|
||||
** (c) Copyright 1998-2000 by Lutz Sammer
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
//
|
||||
// (c) Copyright 1998-2000 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
|
||||
//@{
|
||||
|
||||
|
@ -35,88 +34,104 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#define DEFAULT NULL
|
||||
#define DEFAULT NULL /// use the first slot as default
|
||||
|
||||
/**
|
||||
** Constructions.
|
||||
*/
|
||||
local Construction Constructions[] = {
|
||||
{ { "",
|
||||
{ "construction-0",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "",
|
||||
{ "construction-1",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "",
|
||||
{ "construction-2",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "",
|
||||
{ "construction-3",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "",
|
||||
{ "construction-4",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "",
|
||||
{ "construction-5",
|
||||
{ "",
|
||||
DEFAULT,
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
0,0 },
|
||||
{ { "land construction site (summer,wasteland).png",
|
||||
{ "construction-land",
|
||||
{ "land construction site (summer,wasteland).png",
|
||||
"land construction site (winter).png",
|
||||
DEFAULT,
|
||||
DEFAULT },
|
||||
64,64 },
|
||||
{ { "human shipyard construction site (summer,wasteland).png",
|
||||
{ "construction-human-shipyard",
|
||||
{ "human shipyard construction site (summer,wasteland).png",
|
||||
"human shipyard construction site (winter).png",
|
||||
DEFAULT,
|
||||
"human shipyard construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "orc shipyard construction site (summer,wasteland).png",
|
||||
{ "construction-orc-shipyard",
|
||||
{ "orc shipyard construction site (summer,wasteland).png",
|
||||
"orc shipyard construction site (winter).png",
|
||||
DEFAULT,
|
||||
"orc shipyard construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "human oil well construction site (summer).png",
|
||||
{ "construction-human-oil-well",
|
||||
{ "human oil well construction site (summer).png",
|
||||
"human oil well construction site (winter).png",
|
||||
"human oil well construction site (wasteland).png",
|
||||
"human oil well construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "orc oil well construction site (summer).png",
|
||||
{ "construction-orc-oil-well",
|
||||
{ "orc oil well construction site (summer).png",
|
||||
"orc oil well construction site (winter).png",
|
||||
"orc oil well construction site (wasteland).png",
|
||||
"orc oil well construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "human refinery construction site (summer,wasteland).png",
|
||||
{ "construction-human-refinery",
|
||||
{ "human refinery construction site (summer,wasteland).png",
|
||||
"human refinery construction site (winter).png",
|
||||
DEFAULT,
|
||||
"human refinery construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "orc refinery construction site (summer,wasteland).png",
|
||||
{ "construction-orc-refinery",
|
||||
{ "orc refinery construction site (summer,wasteland).png",
|
||||
"orc refinery construction site (winter).png",
|
||||
DEFAULT,
|
||||
"orc refinery construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "human foundry construction site (summer,wasteland).png",
|
||||
{ "construction-human-foundry",
|
||||
{ "human foundry construction site (summer,wasteland).png",
|
||||
"human foundry construction site (winter).png",
|
||||
DEFAULT,
|
||||
"human foundry construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "orc foundry construction site (summer,wasteland).png",
|
||||
{ "construction-orc-foundry",
|
||||
{ "orc foundry construction site (summer,wasteland).png",
|
||||
"orc foundry construction site (winter).png",
|
||||
DEFAULT,
|
||||
"orc foundry construction site (swamp).png" },
|
||||
96,96 },
|
||||
{ { "wall construction site (summer).png",
|
||||
{ "construction-wall",
|
||||
{ "wall construction site (summer).png",
|
||||
"wall construction site (winter).png",
|
||||
"wall construction site (wasteland).png",
|
||||
DEFAULT },
|
||||
|
@ -149,13 +164,8 @@ global void LoadConstructions(void)
|
|||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphic/"),file);
|
||||
ShowLoadProgress("\tConstruction %s\n",file);
|
||||
#ifdef NEW_VIDEO
|
||||
Constructions[i].Sprite=LoadSprite(file
|
||||
,Constructions[i].Width,Constructions[i].Height);
|
||||
#else
|
||||
Constructions[i].RleSprite=LoadRleSprite(file
|
||||
,Constructions[i].Width,Constructions[i].Height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +178,6 @@ global void LoadConstructions(void)
|
|||
** @param x X position.
|
||||
** @param y Y position.
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
global void DrawConstruction(int type,int frame,int x,int y)
|
||||
{
|
||||
// FIXME: This should be moved to caller/init...
|
||||
|
@ -177,15 +186,5 @@ global void DrawConstruction(int type,int frame,int x,int y)
|
|||
|
||||
VideoDrawClip(Constructions[type].Sprite,frame,x,y);
|
||||
}
|
||||
#else
|
||||
global void DrawConstruction(int type,int frame,int x,int y)
|
||||
{
|
||||
// FIXME: This should be moved to caller/init...
|
||||
x-=Constructions[type].Width/2;
|
||||
y-=Constructions[type].Height/2;
|
||||
|
||||
DrawRleSpriteClipped(Constructions[type].RleSprite,frame,x,y);
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
|
|
@ -278,9 +278,7 @@ global void UpdateDisplay(void)
|
|||
DrawUnits();
|
||||
DrawMapFogOfWar(MapX,MapY);
|
||||
DrawMissiles();
|
||||
#ifdef NEW_VIDEO
|
||||
DrawConsole();
|
||||
#endif
|
||||
SetClipping(0,0,VideoWidth,VideoHeight);
|
||||
}
|
||||
|
||||
|
@ -360,21 +358,12 @@ global void UpdateDisplay(void)
|
|||
// FIXME: this could be written better, less drawing
|
||||
if( update_old_cursor && MustRedraw!=-1 ) {
|
||||
// Draw restored area only if not same.
|
||||
#ifdef NEW_VIDEO
|
||||
if( OldCursorX!=(CursorX-GameCursor->HotX)
|
||||
|| OldCursorY!=(CursorY-GameCursor->HotY)
|
||||
|| OldCursorW!=VideoGraphicWidth(GameCursor->Sprite)
|
||||
|| OldCursorH!=VideoGraphicHeight(GameCursor->Sprite) ) {
|
||||
InvalidateArea(OldCursorX,OldCursorY,OldCursorW,OldCursorH);
|
||||
}
|
||||
#else
|
||||
if( OldCursorX!=(CursorX-GameCursor->HotX)
|
||||
|| OldCursorY!=(CursorY-GameCursor->HotY)
|
||||
|| OldCursorW!=(GameCursor->RleSprite->Width)
|
||||
|| OldCursorH!=(GameCursor->RleSprite->Height) ) {
|
||||
InvalidateArea(OldCursorX,OldCursorY,OldCursorW,OldCursorH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!MustRedraw) {
|
||||
|
@ -440,20 +429,12 @@ global void UpdateDisplay(void)
|
|||
,TheUI.StatusLine.Graphic->Width
|
||||
,TheUI.StatusLine.Graphic->Height);
|
||||
}
|
||||
#ifdef NEW_VIDEO
|
||||
/* if (MustRedraw) */ {
|
||||
// FIXME: JOHNS: That didn't work: if (MustRedraw&RedrawCursor)
|
||||
InvalidateArea(CursorX-GameCursor->HotX,CursorY-GameCursor->HotY
|
||||
,VideoGraphicWidth(GameCursor->Sprite)
|
||||
,VideoGraphicHeight(GameCursor->Sprite));
|
||||
}
|
||||
#else
|
||||
/* if (MustRedraw) */ {
|
||||
// JOHNS: That didn't work: if (MustRedraw&RedrawCursor)
|
||||
InvalidateArea(CursorX-GameCursor->HotX,CursorY-GameCursor->HotY
|
||||
,GameCursor->RleSprite->Width,GameCursor->RleSprite->Height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,13 +431,8 @@ global void LoadMissileSprites(void)
|
|||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphic/"),file);
|
||||
ShowLoadProgress("\tMissile %s\n",file);
|
||||
#ifdef NEW_VIDEO
|
||||
MissileTypes[i].Sprite=LoadSprite(
|
||||
file,MissileTypes[i].Width,MissileTypes[i].Height);
|
||||
#else
|
||||
MissileTypes[i].RleSprite=LoadRleSprite(
|
||||
file,MissileTypes[i].Width,MissileTypes[i].Height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,13 +455,8 @@ global void LoadMissileSprites(void)
|
|||
}
|
||||
|
||||
MissileTypeSmallFire=MissileTypeByIdent("missile-small-fire");
|
||||
#ifdef NEW_VIDEO
|
||||
// FIXME: FIXME: FIXME: very diry hack
|
||||
MissileTypeSmallFire->Sprite->NumFrames=6;
|
||||
#else
|
||||
// FIXME: FIXME: FIXME: very diry hack
|
||||
MissileTypeSmallFire->RleSprite->NumFrames=6;
|
||||
#endif
|
||||
MissileTypeBigFire=MissileTypeByIdent("missile-big-fire");
|
||||
}
|
||||
|
||||
|
@ -740,21 +730,12 @@ local int MissileVisible(const Missile* missile)
|
|||
*/
|
||||
global void DrawMissile(const MissileType* type,unsigned frame,int x,int y)
|
||||
{
|
||||
#ifdef NEW_VIDEO
|
||||
// FIXME: This is a hack for mirrored sprites
|
||||
if( frame&128 ) {
|
||||
VideoDrawClipX(type->Sprite,frame&127,x,y);
|
||||
} else {
|
||||
VideoDrawClip(type->Sprite,frame,x,y);
|
||||
}
|
||||
#else
|
||||
// FIXME: This is a hack for mirrored sprites
|
||||
if( frame&128 ) {
|
||||
DrawRleSpriteClippedX(type->RleSprite,frame&127,x,y);
|
||||
} else {
|
||||
DrawRleSpriteClipped(type->RleSprite,frame,x,y);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1018,7 +999,6 @@ global void MissileActions(void)
|
|||
// Animate missile, cycle through frames
|
||||
//
|
||||
missile->Frame+=5; // FIXME: frames pro row
|
||||
#ifdef NEW_VIDEO
|
||||
if( (missile->Frame&127)
|
||||
>=VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
missile->Frame-=
|
||||
|
@ -1027,14 +1007,6 @@ global void MissileActions(void)
|
|||
DebugLevel3("Frame %d of %d\n"
|
||||
,missile->Frame
|
||||
,VideoGraphicFrames(missile->Type->Sprite));
|
||||
#else
|
||||
if( (missile->Frame&127)
|
||||
>=missile->Type->RleSprite->NumFrames ) {
|
||||
missile->Frame-=missile->Type->RleSprite->NumFrames;
|
||||
}
|
||||
DebugLevel3("Frame %d of %d\n"
|
||||
,missile->Frame,missile->Type->RleSprite->NumFrames);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1077,7 +1049,6 @@ global void MissileActions(void)
|
|||
// Animate missile, cycle through frames
|
||||
//
|
||||
missile->Frame+=5; // FIXME: frames pro row
|
||||
#ifdef NEW_VIDEO
|
||||
if( (missile->Frame&127)
|
||||
>=VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
missile->Frame-=
|
||||
|
@ -1086,14 +1057,6 @@ global void MissileActions(void)
|
|||
DebugLevel3("Frame %d of %d\n"
|
||||
,missile->Frame
|
||||
,VideoGraphicFrames(missile->Type->Sprite));
|
||||
#else
|
||||
if( (missile->Frame&127)
|
||||
>=missile->Type->RleSprite->NumFrames ) {
|
||||
missile->Frame-=missile->Type->RleSprite->NumFrames;
|
||||
}
|
||||
DebugLevel3("Frame %d of %d\n"
|
||||
,missile->Frame,missile->Type->RleSprite->NumFrames);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1104,36 +1067,21 @@ global void MissileActions(void)
|
|||
// Animate hit
|
||||
//
|
||||
missile->Frame+=5; // FIXME: frames pro row
|
||||
#ifdef NEW_VIDEO
|
||||
if( (missile->Frame&127)
|
||||
>=VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
MissileHit(missile);
|
||||
missile->Type=MissileFree;
|
||||
}
|
||||
#else
|
||||
if( (missile->Frame&127)
|
||||
>=missile->Type->RleSprite->NumFrames ) {
|
||||
MissileHit(missile);
|
||||
missile->Type=MissileFree;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case MissileClassStayWithDelay:
|
||||
missile->Wait=missile->Type->Speed;
|
||||
#ifdef NEW_VIDEO
|
||||
if( ++missile->Frame
|
||||
==VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
MissileHit(missile);
|
||||
missile->Type=MissileFree;
|
||||
}
|
||||
#else
|
||||
if( ++missile->Frame==missile->Type->RleSprite->NumFrames ) {
|
||||
MissileHit(missile);
|
||||
missile->Type=MissileFree;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case MissileClassCycleOnce:
|
||||
|
@ -1144,19 +1092,11 @@ global void MissileActions(void)
|
|||
++missile->State;
|
||||
break;
|
||||
case 1:
|
||||
#ifdef NEW_VIDEO
|
||||
if( ++missile->Frame
|
||||
==VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
--missile->Frame;
|
||||
++missile->State;
|
||||
}
|
||||
#else
|
||||
if( ++missile->Frame
|
||||
==missile->Type->RleSprite->NumFrames ) {
|
||||
--missile->Frame;
|
||||
++missile->State;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
if( !missile->Frame-- ) {
|
||||
|
@ -1169,13 +1109,8 @@ global void MissileActions(void)
|
|||
|
||||
case MissileClassFire:
|
||||
missile->Wait=missile->Type->Speed;
|
||||
#ifdef NEW_VIDEO
|
||||
if( ++missile->Frame
|
||||
==VideoGraphicFrames(missile->Type->Sprite) )
|
||||
#else
|
||||
if( ++missile->Frame==missile->Type->RleSprite->NumFrames )
|
||||
#endif
|
||||
{
|
||||
==VideoGraphicFrames(missile->Type->Sprite) ) {
|
||||
int f;
|
||||
Unit* unit;
|
||||
|
||||
|
|
|
@ -515,8 +515,6 @@ global void PlayersEachSecond(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Change current color set to new player.
|
||||
**
|
||||
|
@ -706,169 +704,6 @@ global void SetPlayersPalette(void)
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
** Change current color set to new player.
|
||||
**
|
||||
** FIXME: use function pointer here.
|
||||
**
|
||||
** @param player Pointer to player.
|
||||
*/
|
||||
global void RLEPlayerPixels(const Player* player, const RleSprite * sprite)
|
||||
{
|
||||
switch(VideoDepth){
|
||||
case 8:
|
||||
*((struct __4pixel8__*)(((VMemType8*)sprite->Pixels)+208))
|
||||
=player->UnitColors.Depth8;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
*((struct __4pixel16__*)(((VMemType16*)sprite->Pixels)+208))
|
||||
=player->UnitColors.Depth16;
|
||||
break;
|
||||
case 24:
|
||||
// FIXME: support for real 24 bpp mode
|
||||
//*((struct __4pixel24__*)(((VMemType24*)sprite->Pixels)+208))
|
||||
// =player->UnitColors.Depth24;
|
||||
case 32:
|
||||
*((struct __4pixel32__*)(((VMemType32*)sprite->Pixels)+208))
|
||||
=player->UnitColors.Depth32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Change current color set to new player.
|
||||
**
|
||||
** @param player Pointer to player.
|
||||
*/
|
||||
global void PlayerPixels(const Player* player)
|
||||
{
|
||||
// FIXME: use function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
*((struct __4pixel8__*)(Pixels8+208))=player->UnitColors.Depth8;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
*((struct __4pixel16__*)(Pixels16+208))=player->UnitColors.Depth16;
|
||||
break;
|
||||
case 24:
|
||||
// FIXME: support for real 24 bpp mode
|
||||
case 32:
|
||||
*((struct __4pixel32__*)(Pixels32+208))=player->UnitColors.Depth32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Setup the player colors for the current palette.
|
||||
**
|
||||
** FIXME: need better colors for the player 8-16.
|
||||
** FIXME: could be called before PixelsXX is setup.
|
||||
*/
|
||||
global void SetPlayersPalette(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
// New player colors setup
|
||||
if( !Pixels8 ) {
|
||||
DebugLevel0(__FUNCTION__": Wrong setup order\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for( i=0; i<7; ++i ) {
|
||||
Players[i].UnitColors.Depth8.Pixels[0]=Pixels8[i*4+208];
|
||||
Players[i].UnitColors.Depth8.Pixels[1]=Pixels8[i*4+209];
|
||||
Players[i].UnitColors.Depth8.Pixels[2]=Pixels8[i*4+210];
|
||||
Players[i].UnitColors.Depth8.Pixels[3]=Pixels8[i*4+211];
|
||||
|
||||
Players[i+8].UnitColors.Depth8.Pixels[0]=Pixels8[i*4+208];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[1]=Pixels8[i*4+209];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[2]=Pixels8[i*4+210];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[3]=Pixels8[i*4+211];
|
||||
}
|
||||
|
||||
Players[i].UnitColors.Depth8.Pixels[0]=Pixels8[12];
|
||||
Players[i].UnitColors.Depth8.Pixels[1]=Pixels8[13];
|
||||
Players[i].UnitColors.Depth8.Pixels[2]=Pixels8[14];
|
||||
Players[i].UnitColors.Depth8.Pixels[3]=Pixels8[15];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[0]=Pixels8[12];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[1]=Pixels8[13];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[2]=Pixels8[14];
|
||||
Players[i+8].UnitColors.Depth8.Pixels[3]=Pixels8[15];
|
||||
|
||||
break;
|
||||
|
||||
case 15:
|
||||
case 16:
|
||||
// New player colors setup
|
||||
if( !Pixels16 ) {
|
||||
DebugLevel0(__FUNCTION__": Wrong setup order\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for( i=0; i<7; ++i ) {
|
||||
Players[i].UnitColors.Depth16.Pixels[0]=Pixels16[i*4+208];
|
||||
Players[i].UnitColors.Depth16.Pixels[1]=Pixels16[i*4+209];
|
||||
Players[i].UnitColors.Depth16.Pixels[2]=Pixels16[i*4+210];
|
||||
Players[i].UnitColors.Depth16.Pixels[3]=Pixels16[i*4+211];
|
||||
|
||||
Players[i+8].UnitColors.Depth16.Pixels[0]=Pixels16[i*4+208];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[1]=Pixels16[i*4+209];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[2]=Pixels16[i*4+210];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[3]=Pixels16[i*4+211];
|
||||
}
|
||||
|
||||
Players[i].UnitColors.Depth16.Pixels[0]=Pixels16[12];
|
||||
Players[i].UnitColors.Depth16.Pixels[1]=Pixels16[13];
|
||||
Players[i].UnitColors.Depth16.Pixels[2]=Pixels16[14];
|
||||
Players[i].UnitColors.Depth16.Pixels[3]=Pixels16[15];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[0]=Pixels16[12];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[1]=Pixels16[13];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[2]=Pixels16[14];
|
||||
Players[i+8].UnitColors.Depth16.Pixels[3]=Pixels16[15];
|
||||
|
||||
break;
|
||||
case 24:
|
||||
// FIXME: support for real 24 bpp mode
|
||||
case 32:
|
||||
// New player colors setup
|
||||
if( !Pixels32 ) {
|
||||
DebugLevel0(__FUNCTION__": Wrong setup order\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for( i=0; i<7; ++i ) {
|
||||
Players[i].UnitColors.Depth32.Pixels[0]=Pixels32[i*4+208];
|
||||
Players[i].UnitColors.Depth32.Pixels[1]=Pixels32[i*4+209];
|
||||
Players[i].UnitColors.Depth32.Pixels[2]=Pixels32[i*4+210];
|
||||
Players[i].UnitColors.Depth32.Pixels[3]=Pixels32[i*4+211];
|
||||
|
||||
Players[i+8].UnitColors.Depth32.Pixels[0]=Pixels32[i*4+208];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[1]=Pixels32[i*4+209];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[2]=Pixels32[i*4+210];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[3]=Pixels32[i*4+211];
|
||||
}
|
||||
|
||||
Players[i].UnitColors.Depth32.Pixels[0]=Pixels32[12];
|
||||
Players[i].UnitColors.Depth32.Pixels[1]=Pixels32[13];
|
||||
Players[i].UnitColors.Depth32.Pixels[2]=Pixels32[14];
|
||||
Players[i].UnitColors.Depth32.Pixels[3]=Pixels32[15];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[0]=Pixels32[12];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[1]=Pixels32[13];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[2]=Pixels32[14];
|
||||
Players[i+8].UnitColors.Depth32.Pixels[3]=Pixels32[15];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Output debug informations for players.
|
||||
*/
|
||||
|
|
|
@ -210,9 +210,7 @@ global void DrawButtonPanel(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
PlayerPixels(ThisPlayer); // could only select own units.
|
||||
#endif
|
||||
|
||||
for( i=0; i<9; ++i ) {
|
||||
if( buttons[i].Pos!=-1 ) {
|
||||
|
@ -272,13 +270,8 @@ global void DrawButtonPanel(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(ThisPlayer,buttons[i].Icon.Icon
|
||||
,v,TheUI.Buttons[i+10].X,TheUI.Buttons[i+10].Y);
|
||||
#else
|
||||
DrawUnitIcon(buttons[i].Icon.Icon
|
||||
,v,TheUI.Buttons[i+10].X,TheUI.Buttons[i+10].Y);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Update status line for this button
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "freecraft.h"
|
||||
#include "video.h"
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -43,6 +41,4 @@ global void DrawConsole(void)
|
|||
DebugLevel3(__FUNCTION__"\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
|
|
@ -399,12 +399,8 @@ global const char* IdentOfIcon(IconId icon)
|
|||
** @param x X display position
|
||||
** @param y Y display position
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
global void DrawUnitIcon(const void* player,IconId icon,unsigned flags
|
||||
,unsigned x,unsigned y)
|
||||
#else
|
||||
global void DrawUnitIcon(IconId icon,unsigned flags,unsigned x,unsigned y)
|
||||
#endif
|
||||
{
|
||||
int color;
|
||||
|
||||
|
@ -430,9 +426,7 @@ global void DrawUnitIcon(IconId icon,unsigned flags,unsigned x,unsigned y)
|
|||
++x; ++y;
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
GraphicPlayerPixels(player,Icons[0].IconGraphic);
|
||||
#endif
|
||||
VideoDrawSub(Icons[0].IconGraphic
|
||||
,(icon%5)*Icons[0].Width,(icon/5)*Icons[0].Height
|
||||
,Icons[0].Width,Icons[0].Height,x+4,y+4);
|
||||
|
|
|
@ -135,18 +135,10 @@ global void DrawUnitInfo(Unit* unit)
|
|||
//
|
||||
x=TheUI.Buttons[1].X;
|
||||
y=TheUI.Buttons[1].Y;
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player,type->Icon.Icon
|
||||
,(ButtonUnderCursor==1)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,x,y);
|
||||
#else
|
||||
PlayerPixels(unit->Player);
|
||||
DrawUnitIcon(type->Icon.Icon
|
||||
,(ButtonUnderCursor==1)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,x,y);
|
||||
#endif
|
||||
DrawLifeBar(unit,x,y);
|
||||
|
||||
x=TheUI.InfoPanelX;
|
||||
|
@ -187,14 +179,9 @@ global void DrawUnitInfo(Unit* unit)
|
|||
if( unit->Command.Action==UnitActionTrain ) {
|
||||
if( OriginalTraining || unit->Command.Data.Train.Count==1 ) {
|
||||
DrawText(x+37,y+8+78,GameFont,"Training:");
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->Command.Data.Train.What[0]->Icon.Icon
|
||||
,0,x+107,y+8+70);
|
||||
#else
|
||||
DrawUnitIcon(unit->Command.Data.Train.What[0]->Icon.Icon
|
||||
,0,x+107,y+8+70);
|
||||
#endif
|
||||
|
||||
DrawCompleted(
|
||||
unit->Command.Data.Train.What[0]
|
||||
|
@ -204,18 +191,11 @@ global void DrawUnitInfo(Unit* unit)
|
|||
DrawTextCentered(x+114,y+8+29,GameFont,"Training...");
|
||||
|
||||
for( i = 0; i < unit->Command.Data.Train.Count; i++ ) {
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->Command.Data.Train.What[i]->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons2[i].X,TheUI.Buttons2[i].Y);
|
||||
#else
|
||||
DrawUnitIcon(unit->Command.Data.Train.What[i]->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons2[i].X,TheUI.Buttons2[i].Y);
|
||||
#endif
|
||||
}
|
||||
|
||||
DrawCompleted(
|
||||
|
@ -227,14 +207,9 @@ global void DrawUnitInfo(Unit* unit)
|
|||
}
|
||||
if( unit->Command.Action==UnitActionUpgradeTo ) {
|
||||
DrawText(x+29,y+8+78,GameFont,"Upgrading:");
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->Command.Data.UpgradeTo.What->Icon.Icon
|
||||
,0,x+107,y+8+70);
|
||||
#else
|
||||
DrawUnitIcon(unit->Command.Data.UpgradeTo.What->Icon.Icon
|
||||
,0,x+107,y+8+70);
|
||||
#endif
|
||||
|
||||
DrawCompleted(
|
||||
unit->Command.Data.UpgradeTo.What
|
||||
|
@ -244,14 +219,9 @@ global void DrawUnitInfo(Unit* unit)
|
|||
}
|
||||
if( unit->Command.Action==UnitActionResearch ) {
|
||||
DrawText(16,y+8+78,GameFont,"Researching:");
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->Command.Data.Research.What->Icon
|
||||
,0,x+107,y+8+70);
|
||||
#else
|
||||
DrawUnitIcon(unit->Command.Data.Research.What->Icon
|
||||
,0,x+107,y+8+70);
|
||||
#endif
|
||||
|
||||
DrawCompleted(
|
||||
unit->Command.Data.Research.What->Costs[TimeCost]
|
||||
|
@ -301,18 +271,11 @@ global void DrawUnitInfo(Unit* unit)
|
|||
DrawText(x+91,y+8+33,GameFont,buf);
|
||||
for( i=0; i<6; ++i ) {
|
||||
if( unit->OnBoard[i]!=NoUnitP ) {
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->OnBoard[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
#else
|
||||
DrawUnitIcon(unit->OnBoard[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
#endif
|
||||
DrawLifeBar(unit->OnBoard[i]
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
// FIXME: show also the magic bar :) I want this always.
|
||||
|
@ -730,18 +693,11 @@ global void DrawInfoPanel(void)
|
|||
PlayerPixels(ThisPlayer); // can only be own!
|
||||
DrawInfoPanelBackground(0);
|
||||
for( i=0; i<NumSelected; ++i ) {
|
||||
#ifdef NEW_VIDEO
|
||||
DrawUnitIcon(ThisPlayer
|
||||
,Selected[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+1)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+1].X,TheUI.Buttons[i+1].Y);
|
||||
#else
|
||||
DrawUnitIcon(Selected[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+1)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+1].X,TheUI.Buttons[i+1].Y);
|
||||
#endif
|
||||
DrawLifeBar(Selected[i]
|
||||
,TheUI.Buttons[i+1].X,TheUI.Buttons[i+1].Y);
|
||||
|
||||
|
|
|
@ -35,11 +35,6 @@
|
|||
#include "interface.h"
|
||||
#include "menus.h"
|
||||
#include "cursor.h"
|
||||
#include "new_video.h"
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
//#error ONLY WORKS WITH NEW VIDEO!
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Prototypes for action handlers
|
||||
|
|
|
@ -2289,13 +2289,8 @@ global void DestroyUnit(Unit* unit)
|
|||
unit->State=unit->Type->CorpseScript;
|
||||
unit->Type=type;
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
unit->IX=(type->Width-VideoGraphicWidth(type->Sprite))/2;
|
||||
unit->IY=(type->Height-VideoGraphicHeight(type->Sprite))/2;
|
||||
#else
|
||||
unit->IX=(type->Width-type->RleSprite->Width)/2;
|
||||
unit->IY=(type->Height-type->RleSprite->Height)/2;
|
||||
#endif
|
||||
|
||||
unit->SubAction=0;
|
||||
unit->Removed=0;
|
||||
|
|
|
@ -108,11 +108,7 @@ typedef struct _decoration_ {
|
|||
int Height; /// height of the decoration
|
||||
|
||||
// --- FILLED UP ---
|
||||
#ifdef NEW_VIDEO
|
||||
Graphic* Sprite; /// loaded sprite images
|
||||
#else
|
||||
RleSprite* RleSprite; /// loaded sprite images
|
||||
#endif
|
||||
} Decoration;
|
||||
|
||||
/**
|
||||
|
@ -187,21 +183,12 @@ global SCM CclHealthSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
|
|||
*/
|
||||
global void LoadDecorations(void)
|
||||
{
|
||||
#ifdef NEW_VIDEO
|
||||
HealthSprite.Sprite=LoadSprite(HealthSprite.File
|
||||
,HealthSprite.Width,HealthSprite.Height);
|
||||
ManaSprite.Sprite=LoadSprite(ManaSprite.File
|
||||
,ManaSprite.Width,ManaSprite.Height);
|
||||
ShadowSprite.Sprite=LoadSprite(ShadowSprite.File
|
||||
,ShadowSprite.Width,ShadowSprite.Height);
|
||||
#else
|
||||
HealthSprite.RleSprite=LoadRleSprite(HealthSprite.File
|
||||
,HealthSprite.Width,HealthSprite.Height);
|
||||
ManaSprite.RleSprite=LoadRleSprite(ManaSprite.File
|
||||
,ManaSprite.Width,ManaSprite.Height);
|
||||
ShadowSprite.RleSprite=LoadRleSprite(ShadowSprite.File
|
||||
,ShadowSprite.Width,ShadowSprite.Height);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,11 +268,7 @@ local void DrawDecoration(Unit* unit,const UnitType* type,int x,int y)
|
|||
+(type->TileHeight*TileSizeY
|
||||
-type->BoxHeight+1)/2;
|
||||
}
|
||||
#ifdef NEW_VIDEO
|
||||
VideoDrawClip(HealthSprite.Sprite,n,x1,y1);
|
||||
#else
|
||||
DrawRleSpriteClipped(HealthSprite.RleSprite,n,x1,y1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,12 +306,8 @@ local void DrawDecoration(Unit* unit,const UnitType* type,int x,int y)
|
|||
} else if( f>25 ) {
|
||||
n=2;
|
||||
// FIXME: v--- compatibility hack
|
||||
#ifdef NEW_VIDEO
|
||||
} else if( f
|
||||
&& ManaSprite.Width*4<VideoGraphicWidth(ManaSprite.Sprite) ) {
|
||||
#else
|
||||
} else if( f && ManaSprite.Width*4<ManaSprite.RleSprite->Width ) {
|
||||
#endif
|
||||
n=3;
|
||||
} else {
|
||||
n=4;
|
||||
|
@ -351,11 +330,7 @@ local void DrawDecoration(Unit* unit,const UnitType* type,int x,int y)
|
|||
+(type->TileHeight*TileSizeY
|
||||
-type->BoxHeight+1)/2;
|
||||
}
|
||||
#ifdef NEW_VIDEO
|
||||
VideoDrawClip(ManaSprite.Sprite,n,x1,y1);
|
||||
#else
|
||||
DrawRleSpriteClipped(ManaSprite.RleSprite,n,x1,y1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,13 +361,8 @@ local void DrawShadow(Unit* unit,UnitType* type,int x,int y)
|
|||
}
|
||||
DebugLevel3("Box-height %d\n",type->BoxHeight);
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
VideoDrawClip(ShadowSprite.Sprite,i
|
||||
,x+ShadowSprite.HotX,y+ShadowSprite.HotY);
|
||||
#else
|
||||
DrawRleSpriteClipped(ShadowSprite.RleSprite,i
|
||||
,x+ShadowSprite.HotX,y+ShadowSprite.HotY);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -584,11 +554,7 @@ local void DrawBuilding(Unit* unit)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
GraphicPlayerPixels(unit->Player,unit->Type->Sprite);
|
||||
#else
|
||||
RLEPlayerPixels(unit->Player,unit->Type->RleSprite);
|
||||
#endif
|
||||
x=Map2ScreenX(unit->X)+unit->IX;
|
||||
y=Map2ScreenY(unit->Y)+unit->IY;
|
||||
|
||||
|
@ -596,11 +562,7 @@ local void DrawBuilding(Unit* unit)
|
|||
// Buildings under construction/upgrade/ready.
|
||||
//
|
||||
if( unit->Command.Action==UnitActionBuilded ) {
|
||||
#ifdef NEW_VIDEO
|
||||
if( unit->Constructed || VideoGraphicFrames(type->Sprite)<=1 ) {
|
||||
#else
|
||||
if( unit->Constructed || type->RleSprite->NumFrames<=1 ) {
|
||||
#endif
|
||||
DrawConstruction(type->OverlapFrame
|
||||
,frame&127
|
||||
,x+(type->TileWidth*TileSizeX)/2
|
||||
|
@ -645,11 +607,7 @@ local void DrawUnit(Unit* unit)
|
|||
|
||||
DrawSelectionRectangle(unit,type,x,y);
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
GraphicPlayerPixels(unit->Player,unit->Type->Sprite);
|
||||
#else
|
||||
RLEPlayerPixels(unit->Player,unit->Type->RleSprite);
|
||||
#endif
|
||||
DrawUnitType(type,unit->Frame,x,y);
|
||||
|
||||
stats=unit->Stats;
|
||||
|
|
|
@ -1105,13 +1105,8 @@ global void LoadUnitSprites(void)
|
|||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphic/"),file);
|
||||
ShowLoadProgress("\tUnit `%s'\n",file);
|
||||
#ifdef NEW_VIDEO
|
||||
UnitTypes[type].Sprite=LoadSprite(file
|
||||
,UnitTypes[type].Width,UnitTypes[type].Height);
|
||||
#else
|
||||
UnitTypes[type].RleSprite=LoadRleSprite(file
|
||||
,UnitTypes[type].Width,UnitTypes[type].Height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1126,11 +1121,7 @@ global void LoadUnitSprites(void)
|
|||
,UnitTypes[type].SameSprite);
|
||||
exit(-1);
|
||||
}
|
||||
#ifdef NEW_VIDEO
|
||||
UnitTypes[type].Sprite=unittype->Sprite;
|
||||
#else
|
||||
UnitTypes[type].RleSprite=unittype->RleSprite;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1172,19 +1163,11 @@ global void DrawUnitType(const UnitType* type,unsigned frame,int x,int y)
|
|||
y-=(type->Height-type->TileHeight*TileSizeY)/2;
|
||||
|
||||
// FIXME: This is a hack for mirrored sprites
|
||||
#ifdef NEW_VIDEO
|
||||
if( frame&128 ) {
|
||||
VideoDrawClipX(type->Sprite,frame&127,x,y);
|
||||
} else {
|
||||
VideoDrawClip(type->Sprite,frame,x,y);
|
||||
}
|
||||
#else
|
||||
if( frame&128 ) {
|
||||
DrawRleSpriteClippedX(type->RleSprite,frame&127,x,y);
|
||||
} else {
|
||||
DrawRleSpriteClipped(type->RleSprite,frame,x,y);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -20,7 +20,7 @@ TOPDIR = ../..
|
|||
include $(TOPDIR)/Rules.make
|
||||
|
||||
MODULE = video
|
||||
OBJS = new_video.$(OE) video.$(OE) cursor.$(OE) sprite.$(OE) \
|
||||
OBJS = video.$(OE) cursor.$(OE) sprite.$(OE) \
|
||||
graphic.$(OE) linedraw.$(OE) font.$(OE) png.$(OE) \
|
||||
sdl.$(OE) new_X11.$(OE) X11.$(OE) svgalib.$(OE)
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
#ifdef USE_X11
|
||||
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
// FIXME: move this and clean up to new_X11.
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -60,28 +65,6 @@
|
|||
#include "ui.h"
|
||||
#include "new_video.h"
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Architecture-dependant video memory. Set by InitVideoXXX.
|
||||
**
|
||||
** @see InitVideo
|
||||
*/
|
||||
global void* VideoMemory;
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by InitVideoXXX.
|
||||
**
|
||||
** @see InitVideo
|
||||
*/
|
||||
global int VideoDepth;
|
||||
|
||||
global VMemType8 * Pixels8;
|
||||
global VMemType16 * Pixels16;
|
||||
global VMemType32 * Pixels32;
|
||||
|
||||
#endif
|
||||
|
||||
local Display* TheDisplay; /// My X11 display
|
||||
local int TheScreen; /// My X11 screen
|
||||
local Window TheMainWindow; /// My X11 window
|
||||
|
@ -94,11 +77,6 @@ local Atom WmDeleteWindowAtom; /// Atom for WM_DELETE_WINDOW
|
|||
-- Sync
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
global int VideoSyncSpeed=100; // 0 disable interrupts
|
||||
volatile int VideoInterrupts; // be happy, were are quicker
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Called from SIGALRM.
|
||||
*/
|
||||
|
@ -839,11 +817,7 @@ global void WaitEventsAndKeepSync(void)
|
|||
**
|
||||
** @returns A hardware dependend pixel table.
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
global VMemType* VideoCreateNewPalette(const Palette *palette)
|
||||
#else
|
||||
global GraphicData * VideoCreateNewPalette(const Palette *palette)
|
||||
#endif
|
||||
{
|
||||
XColor color;
|
||||
XWindowAttributes xwa;
|
||||
|
@ -934,118 +908,6 @@ global GraphicData * VideoCreateNewPalette(const Palette *palette)
|
|||
return pixels;
|
||||
}
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Color cycle.
|
||||
*/
|
||||
global void ColorCycle(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
|
||||
// FIXME: this isn't 100% correct
|
||||
// Color cycling info - forest:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 48-56 cycle (water-coast boundary)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - swamp:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 4 pulsates red (Circle of Power)
|
||||
// 5-9 cycle (Runestone, Dark Portal)
|
||||
// 38-47 cycle (water)
|
||||
// 88-95 cycle (waterholes in coast and ground)
|
||||
// 240-244 cycle (water around ships)
|
||||
// Color cycling info - wasteland:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 64-70 cycle (coast)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - winter:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 40-47 cycle (water)
|
||||
// 48-54 cycle (half-sunken ice-floe)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 205-207 cycle (lights on christmas tree)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
|
||||
// FIXME: function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
x = ((VMemType8*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType8*)TheMap.TileData->Pixels)[i] =
|
||||
((VMemType8*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType8*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
x=Pixels8[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[47]=x;
|
||||
|
||||
x=Pixels8[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[244]=x;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
x = ((VMemType16*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType16*)TheMap.TileData->Pixels)[i] =
|
||||
((VMemType16*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType16*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
x=Pixels16[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[47]=x;
|
||||
|
||||
x=Pixels16[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[244]=x;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
x = ((VMemType32*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType32*)TheMap.TileData->Pixels)[i] =
|
||||
((VMemType32*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType32*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
|
||||
|
||||
x=Pixels32[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[47]=x;
|
||||
|
||||
x=Pixels32[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[244]=x;
|
||||
break;
|
||||
}
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Check video interrupt.
|
||||
**
|
||||
|
@ -1062,13 +924,6 @@ global void CheckVideoInterrupts(void)
|
|||
,False);
|
||||
);
|
||||
++SlowFrameCounter;
|
||||
#if 0
|
||||
} else {
|
||||
struct itimerval itv;
|
||||
|
||||
getitimer(ITIMER_REAL,&itv);
|
||||
DebugLevel1("Remain %d\n",itv.it_value.tv_usec);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,19 +139,15 @@ global int OldCursorH; /// saved cursor height in pixel
|
|||
global int OldCursorSize; /// size of saved cursor image
|
||||
global void* OldCursorImage; /// background saved behind cursor
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/// Save background behind cursor
|
||||
/// Function pointer: Save background behind cursor
|
||||
local void (*SaveCursorBackground)(int,int,int,int);
|
||||
/// Load background behind cursor
|
||||
/// Function pointer: Load background behind cursor
|
||||
local void (*LoadCursorBackground)(int,int,int,int);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Restore cursor background for 8bpp frame buffer.
|
||||
**
|
||||
|
@ -368,8 +364,6 @@ local void SaveCursorBackground32(int x,int y,int w,int h)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Load all cursor sprites.
|
||||
**
|
||||
|
@ -387,15 +381,8 @@ global void LoadCursors(unsigned int race)
|
|||
|
||||
if (last_race != -1) { // free previous sprites for different race
|
||||
for( i=0; i<sizeof(Cursors)/sizeof(*Cursors); ++i ) {
|
||||
#ifdef NEW_VIDEO
|
||||
VideoSaveFree(Cursors[i].Sprite);
|
||||
Cursors[i].Sprite = NULL;
|
||||
#else
|
||||
if (Cursors[i].RleSprite) {
|
||||
FreeRleSprite(Cursors[i].RleSprite);
|
||||
Cursors[i].RleSprite = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
last_race = race;
|
||||
|
@ -414,14 +401,8 @@ global void LoadCursors(unsigned int race)
|
|||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphic/"),file);
|
||||
ShowLoadProgress("\tCursor %s\n",file);
|
||||
#ifdef NEW_VIDEO
|
||||
Cursors[i].Sprite=LoadSprite(file,0,0);
|
||||
// FIXME: real size?
|
||||
#else
|
||||
Cursors[i].RleSprite=LoadRleSprite(file,0,0);
|
||||
// FIXME: this is hack!!
|
||||
//,Cursors[i].Width,Cursors[i].Height);
|
||||
#endif
|
||||
Cursors[i].Sprite=LoadSprite(file,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -431,9 +412,6 @@ global void LoadCursors(unsigned int race)
|
|||
*/
|
||||
local void SaveCursor(void)
|
||||
{
|
||||
#ifndef NEW_VIDEO
|
||||
int i;
|
||||
#endif
|
||||
int w;
|
||||
int h;
|
||||
int x;
|
||||
|
@ -465,72 +443,7 @@ local void SaveCursor(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
SaveCursorBackground(x,y,w,h);
|
||||
#else
|
||||
// FIXME: use function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
i=w*h*sizeof(VMemType8);
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
i=w*h*sizeof(VMemType16);
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
default:
|
||||
i=w*h*sizeof(VMemType32);
|
||||
break;
|
||||
}
|
||||
if( OldCursorSize<i ) {
|
||||
if( OldCursorImage ) {
|
||||
OldCursorImage=realloc(OldCursorImage,i);
|
||||
} else {
|
||||
OldCursorImage=malloc(i);
|
||||
}
|
||||
DebugLevel3("Cursor memory %d\n",i);
|
||||
OldCursorSize=i;
|
||||
}
|
||||
// FIXME: use function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
{ VMemType8 *dp;
|
||||
VMemType8 *sp;
|
||||
dp=OldCursorImage;
|
||||
sp=VideoMemory8+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType8));
|
||||
dp+=w;
|
||||
sp+=VideoWidth;
|
||||
}
|
||||
break; }
|
||||
case 15:
|
||||
case 16:
|
||||
{ VMemType16 *dp;
|
||||
VMemType16 *sp;
|
||||
dp=OldCursorImage;
|
||||
sp=VideoMemory16+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType16));
|
||||
dp+=w;
|
||||
sp+=VideoWidth;
|
||||
}
|
||||
break; }
|
||||
case 24:
|
||||
case 32:
|
||||
{ VMemType32 *dp;
|
||||
VMemType32 *sp;
|
||||
dp=OldCursorImage;
|
||||
sp=VideoMemory32+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType32));
|
||||
dp+=w;
|
||||
sp+=VideoWidth;
|
||||
}
|
||||
break; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -538,24 +451,14 @@ local void SaveCursor(void)
|
|||
*/
|
||||
local void RestoreCursor(void)
|
||||
{
|
||||
#ifndef NEW_VIDEO
|
||||
void *dp;
|
||||
void *sp;
|
||||
#endif
|
||||
int w;
|
||||
int h;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
if( !OldCursorImage ) { // no cursor saved
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if( !(sp=OldCursorImage) ) { // no cursor saved
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME: I should better store the correct values on save.
|
||||
x=OldCursorX;
|
||||
|
@ -584,38 +487,7 @@ local void RestoreCursor(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
LoadCursorBackground(x,y,w,h);
|
||||
#else
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
dp=VideoMemory8+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType8));
|
||||
((VMemType8*)sp)+=w;
|
||||
((VMemType8*)dp)+=VideoWidth;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
dp=VideoMemory16+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType16));
|
||||
((VMemType16*)sp)+=w;
|
||||
((VMemType16*)dp)+=VideoWidth;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
dp=VideoMemory32+y*VideoWidth+x;
|
||||
while( h-- ) {
|
||||
memcpy(dp,sp,w*sizeof(VMemType32));
|
||||
((VMemType32*)sp)+=w;
|
||||
((VMemType32*)dp)+=VideoWidth;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -626,7 +498,6 @@ local void RestoreCursor(void)
|
|||
*/
|
||||
global void DrawCursor(CursorType* type,int x,int y,int frame)
|
||||
{
|
||||
#ifdef NEW_VIDEO
|
||||
OldCursorX=x-=type->HotX;
|
||||
OldCursorY=y-=type->HotY;
|
||||
OldCursorW=VideoGraphicWidth(type->Sprite);
|
||||
|
@ -634,15 +505,6 @@ global void DrawCursor(CursorType* type,int x,int y,int frame)
|
|||
|
||||
SaveCursor();
|
||||
VideoDrawClip(type->Sprite,frame,x,y);
|
||||
#else
|
||||
OldCursorX=x-=type->HotX;
|
||||
OldCursorY=y-=type->HotY;
|
||||
OldCursorW=type->RleSprite->Width;
|
||||
OldCursorH=type->RleSprite->Height;
|
||||
|
||||
SaveCursor();
|
||||
DrawRleSpriteClipped(type->RleSprite,frame,x,y);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -686,12 +548,11 @@ local void DrawBuildingCursor(void)
|
|||
//
|
||||
// Draw building
|
||||
//
|
||||
PlayerPixels(ThisPlayer);
|
||||
SetClipping(TheUI.MapX,TheUI.MapY
|
||||
,TheUI.MapWidth,TheUI.MapHeight);
|
||||
PushClipping();
|
||||
SetClipping(TheUI.MapX,TheUI.MapY,TheUI.MapWidth,TheUI.MapHeight);
|
||||
GraphicPlayerPixels(ThisPlayer,CursorBuilding->Sprite);
|
||||
DrawUnitType(CursorBuilding,0,x,y);
|
||||
// FIXME: This is dangerous here
|
||||
SetClipping(0,0,VideoWidth,VideoHeight);
|
||||
PopClipping();
|
||||
|
||||
//
|
||||
// Draw the allow overlay
|
||||
|
@ -867,7 +728,6 @@ global int HideAnyCursor(void)
|
|||
*/
|
||||
global void InitCursor(void)
|
||||
{
|
||||
#ifdef NEW_VIDEO
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
SaveCursorBackground=SaveCursorBackground8;
|
||||
|
@ -890,7 +750,6 @@ global void InitCursor(void)
|
|||
DebugLevel0(__FUNCTION__": unsupported %d bpp\n",VideoDepth);
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -509,11 +509,8 @@ global Graphic* LoadGraphic(const char* name)
|
|||
}
|
||||
//Palette Not found
|
||||
if(current_link == NULL){
|
||||
#ifdef NEW_VIDEO
|
||||
pixels = VideoCreateNewPalette(graphic->Palette);
|
||||
#else
|
||||
pixels = (void*)VideoCreateNewPalette(graphic->Palette);
|
||||
#endif
|
||||
|
||||
DebugLevel0("loading new palette with %s\n",name);
|
||||
if(prev_link == NULL){
|
||||
palette_list = (PaletteLink *)malloc(sizeof(PaletteLink));
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name new_X11.c - XWindows support. */
|
||||
/*
|
||||
** (c) Copyright 1998-2000 by Lutz Sammer and Valery Shchedrin
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
//
|
||||
// (c) Copyright 1998-2000 by Lutz Sammer and Valery Shchedrin
|
||||
//
|
||||
// $Id$
|
||||
|
||||
//@{
|
||||
|
||||
|
@ -25,8 +24,11 @@
|
|||
|
||||
#ifdef USE_X11 // {
|
||||
|
||||
// FIXME: move the cleanup X11 source to here!
|
||||
|
||||
#include "video.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -44,9 +46,8 @@
|
|||
*/
|
||||
global void InitVideoX11(void)
|
||||
{
|
||||
#ifdef NEW_VIDEO
|
||||
extern void GameInitDisplay(void);
|
||||
#endif
|
||||
|
||||
GameInitDisplay(); // Fall back to old function
|
||||
}
|
||||
|
||||
|
|
|
@ -1,545 +0,0 @@
|
|||
// ___________ _________ _____ __
|
||||
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
|
||||
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
|
||||
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
|
||||
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
|
||||
// \/ \/ \/ \/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name video.c - The universal video functions. */
|
||||
/*
|
||||
** (c) Copyright 1999,2000 by Lutz Sammer
|
||||
**
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
#include "video.h"
|
||||
|
||||
#include "map.h"
|
||||
#include "ui.h"
|
||||
#include "cursor.h"
|
||||
|
||||
#ifdef USE_SDL
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
// JOHNS: This is needed, because later I want to support it all with the same
|
||||
// executable, choosable at runtime.
|
||||
#ifdef USE_X11
|
||||
#define UseX11 1
|
||||
#define UseSdl 0
|
||||
#define UseSVGALib 0
|
||||
#define UseWin32 0
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL
|
||||
#define UseX11 0
|
||||
#define UseSdl 1
|
||||
#define UseSVGALib 0
|
||||
#define UseWin32 0
|
||||
#endif
|
||||
|
||||
#ifdef USE_SVGALIB
|
||||
#define UseX11 0
|
||||
#define UseSdl 0
|
||||
#define UseSVGALib 1
|
||||
#define UseWin32 0
|
||||
#endif
|
||||
|
||||
#ifdef noUSE_WIN32
|
||||
#define UseX11 0
|
||||
#define UseSdl 0
|
||||
#define UseSVGALib 0
|
||||
#define UseWin32 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Structure of pushed clippings.
|
||||
*/
|
||||
typedef struct _clip_ {
|
||||
struct _clip_* Next; /// next pushed clipping.
|
||||
int X1; /// pushed clipping top left
|
||||
int Y1; /// pushed clipping top left
|
||||
int X2; /// pushed clipping bottom right
|
||||
int Y2; /// pushed clipping bottom right
|
||||
} Clip;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Externals
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern void InitVideoSdl(void);
|
||||
extern void InitVideoX11(void);
|
||||
extern void InitVideoSVGA(void);
|
||||
extern void InitVideoWin32(void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
global char VideoFullScreen; /// true fullscreen wanted
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
|
||||
global int ClipX1; /// current clipping top left
|
||||
global int ClipY1; /// current clipping top left
|
||||
global int ClipX2; /// current clipping bottom right
|
||||
global int ClipY2; /// current clipping bottom right
|
||||
|
||||
local Clip* Clips; /// stack of all clips.
|
||||
|
||||
#ifdef DEBUG
|
||||
global unsigned AllocatedGraphicMemory; /// Allocated memory for objects
|
||||
global unsigned CompressedGraphicMemory;/// memory for compressed objects
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by InitVideoXXX, if 0.
|
||||
** (8,15,16,24,32)
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see main
|
||||
*/
|
||||
global int VideoDepth;
|
||||
|
||||
/**
|
||||
** Architecture-dependant videomemory. Set by InitVideoXXX.
|
||||
** FIXME: need a new function to set it, see #ifdef SDL code
|
||||
** @see InitVideo @see InitVideoX11 @see InitVideoSVGA @see InitVideoSdl
|
||||
** @see InitVideoWin32 @see VMemType
|
||||
*/
|
||||
global VMemType* VideoMemory;
|
||||
|
||||
/**
|
||||
** Architecture-dependant system palette. Applies as conversion between
|
||||
** GlobalPalette colors and their representation in videomemory.
|
||||
** Set by VideoCreatePalette or VideoSetPalette.
|
||||
** @see VideoCreatePalette @VideoSetPalette
|
||||
*/
|
||||
global VMemType* Pixels;
|
||||
|
||||
global int VideoSyncSpeed=100; /// 0 disable interrupts
|
||||
global volatile int VideoInterrupts; /// be happy, were are quicker
|
||||
|
||||
#endif
|
||||
|
||||
/// Loaded system palette. 256-entries long, active system palette.
|
||||
global Palette GlobalPalette[256];
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/// Does ColorCycling..
|
||||
global void (*ColorCycle)(void);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
/**
|
||||
** Set clipping for graphic routines.
|
||||
**
|
||||
** @param left Left X screen coordinate.
|
||||
** @param top Top Y screen coordinate.
|
||||
** @param right Right X screen coordinate.
|
||||
** @param bottom Bottom Y screen coordinate.
|
||||
*/
|
||||
global void SetClipping(int left,int top,int right,int bottom)
|
||||
{
|
||||
if( left>right ) { left^=right; right^=left; left^=right; }
|
||||
if( top>bottom ) { top^=bottom; bottom^=top; top^=bottom; }
|
||||
|
||||
if( left<0 ) left=0;
|
||||
if( top<0 ) top=0;
|
||||
if( right<0 ) right=0;
|
||||
if( bottom<0 ) bottom=0;
|
||||
|
||||
if( left>=VideoWidth ) left=VideoWidth-1;
|
||||
if( right>=VideoWidth ) right=VideoWidth-1;
|
||||
if( bottom>=VideoHeight ) bottom=VideoHeight-1;
|
||||
if( top>=VideoHeight ) top=VideoHeight-1;
|
||||
|
||||
ClipX1=left;
|
||||
ClipY1=top;
|
||||
ClipX2=right;
|
||||
ClipY2=bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
** Push current clipping.
|
||||
*/
|
||||
global void PushClipping(void)
|
||||
{
|
||||
Clip* clip;
|
||||
|
||||
clip=malloc(sizeof(Clip));
|
||||
clip->Next=Clips;
|
||||
clip->X1=ClipX1;
|
||||
clip->Y1=ClipY1;
|
||||
clip->X2=ClipX2;
|
||||
clip->Y2=ClipY2;
|
||||
Clips=clip;
|
||||
}
|
||||
|
||||
/**
|
||||
** Pop current clipping.
|
||||
*/
|
||||
global void PopClipping(void)
|
||||
{
|
||||
Clip* clip;
|
||||
|
||||
clip=Clips;
|
||||
if( clip ) {
|
||||
Clips=clip->Next;
|
||||
ClipX1=clip->X1;
|
||||
ClipY1=clip->Y1;
|
||||
ClipX2=clip->X2;
|
||||
ClipY2=clip->Y2;
|
||||
free(clip);
|
||||
} else {
|
||||
ClipX1=0;
|
||||
ClipY1=0;
|
||||
ClipX2=VideoWidth;
|
||||
ClipY2=VideoHeight;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Load a picture and display it on the screen (full screen),
|
||||
** changing the colormap and so on..
|
||||
**
|
||||
** @param name Name of the picture (file) to display.
|
||||
*/
|
||||
global void DisplayPicture(const char *name)
|
||||
{
|
||||
Graphic* title;
|
||||
|
||||
title=LoadGraphic(name);
|
||||
#ifdef NEW_VIDEO
|
||||
VideoSetPalette((VMemType*)title->Pixels);
|
||||
#else
|
||||
VideoSetPalette(title->Pixels);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL
|
||||
// FIXME: should be moved to system/hardware dependend part
|
||||
{ extern SDL_Surface *Screen; /// internal screen
|
||||
SDL_LockSurface(Screen);
|
||||
|
||||
VideoMemory=Screen->pixels;
|
||||
#endif
|
||||
|
||||
// FIXME: bigger window ?
|
||||
VideoDrawSubClip(title,0,0
|
||||
,title->Width,title->Height
|
||||
,(VideoWidth-title->Width)/2,(VideoHeight-title->Height)/2);
|
||||
|
||||
#ifdef USE_SDL
|
||||
// FIXME: should be moved to system/hardware dependend part
|
||||
SDL_UnlockSurface(Screen); }
|
||||
#endif
|
||||
VideoFree(title);
|
||||
// FIXME: (ARI:) New Palette got stuck in memory?
|
||||
}
|
||||
|
||||
#ifdef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Load palette from resource. Just loads palette, to set it use
|
||||
** VideoCreatePalette, which sets system palette.
|
||||
**
|
||||
** @param pal buffer to store palette (256-entries long)
|
||||
** @param name resource file name
|
||||
**
|
||||
** @see VideoCreatePalette
|
||||
*/
|
||||
global void LoadRGB(Palette *pal, const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
if((fp=fopen(name,"rb")) == NULL) {
|
||||
fprintf(stderr,"Can't load palette %s\n",name);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i=0;i<256;i++){
|
||||
pal[i].r=fgetc(fp)<<2;
|
||||
pal[i].g=fgetc(fp)<<2;
|
||||
pal[i].b=fgetc(fp)<<2;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
// FIXME: this isn't 100% correct
|
||||
// Color cycling info - forest:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 48-56 cycle (water-coast boundary)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - swamp:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 4 pulsates red (Circle of Power)
|
||||
// 5-9 cycle (Runestone, Dark Portal)
|
||||
// 38-47 cycle (water)
|
||||
// 88-95 cycle (waterholes in coast and ground)
|
||||
// 240-244 cycle (water around ships)
|
||||
// Color cycling info - wasteland:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 64-70 cycle (coast)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - winter:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 40-47 cycle (water)
|
||||
// 48-54 cycle (half-sunken ice-floe)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 205-207 cycle (lights on christmas tree)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
|
||||
/**
|
||||
** Color cycle for 8 bpp video mode.
|
||||
**
|
||||
** FIXME: not correct cycles only palette of tileset.
|
||||
** FIXME: Also icons and some units use color cycling.
|
||||
** FIXME: must be configured by the tileset or global.
|
||||
*/
|
||||
global void ColorCycle8(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
VMemType8* pixels;
|
||||
|
||||
//
|
||||
// Color cycle tileset palette
|
||||
//
|
||||
pixels=TheMap.TileData->Pixels;
|
||||
x = pixels[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
pixels[i] = pixels[i+1];
|
||||
}
|
||||
pixels[47] = x;
|
||||
|
||||
x=Pixels8[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[47]=x;
|
||||
|
||||
x=Pixels8[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[244]=x;
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
** Color cycle for 16 bpp video mode.
|
||||
**
|
||||
** FIXME: not correct cycles only palette of tileset.
|
||||
** FIXME: Also icons and some units use color cycling.
|
||||
** FIXME: must be configured by the tileset or global.
|
||||
*/
|
||||
global void ColorCycle16(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
VMemType16* pixels;
|
||||
|
||||
//
|
||||
// Color cycle tileset palette
|
||||
//
|
||||
pixels=TheMap.TileData->Pixels;
|
||||
x = pixels[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
pixels[i] = pixels[i+1];
|
||||
}
|
||||
pixels[47] = x;
|
||||
|
||||
x=Pixels16[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[47]=x;
|
||||
|
||||
x=Pixels16[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[244]=x;
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
** Color cycle for 24 bpp video mode.
|
||||
**
|
||||
** FIXME: not correct cycles only palette of tileset.
|
||||
** FIXME: Also icons and some units use color cycling.
|
||||
** FIXME: must be configured by the tileset or global.
|
||||
*/
|
||||
global void ColorCycle24(void)
|
||||
{
|
||||
int i;
|
||||
VMemType24 x;
|
||||
VMemType24* pixels;
|
||||
|
||||
//
|
||||
// Color cycle tileset palette
|
||||
//
|
||||
pixels=TheMap.TileData->Pixels;
|
||||
x = pixels[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
pixels[i] = pixels[i+1];
|
||||
}
|
||||
pixels[47] = x;
|
||||
|
||||
x=Pixels24[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels24[i]=Pixels24[i+1];
|
||||
}
|
||||
Pixels24[47]=x;
|
||||
|
||||
x=Pixels24[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels24[i]=Pixels24[i+1];
|
||||
}
|
||||
Pixels24[244]=x;
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
** Color cycle for 32 bpp video mode.
|
||||
**
|
||||
** FIXME: not correct cycles only palette of tileset.
|
||||
** FIXME: Also icons and some units use color cycling.
|
||||
** FIXME: must be configured by the tileset or global.
|
||||
*/
|
||||
global void ColorCycle32(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
VMemType32* pixels;
|
||||
|
||||
//
|
||||
// Color cycle tileset palette
|
||||
//
|
||||
pixels=TheMap.TileData->Pixels;
|
||||
x = pixels[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
pixels[i] = pixels[i+1];
|
||||
}
|
||||
pixels[47] = x;
|
||||
|
||||
x=Pixels32[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[47]=x;
|
||||
|
||||
x=Pixels32[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[244]=x;
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
** Initializes system palette. Also calls SetPlayersPalette to set
|
||||
** palette for all players.
|
||||
**
|
||||
** @param palette VMemType structure, as created by VideoCreateNewPalette
|
||||
** @see SetPlayersPalette
|
||||
*/
|
||||
global void VideoSetPalette(const VMemType* palette)
|
||||
{
|
||||
if( Pixels ) {
|
||||
free(Pixels);
|
||||
}
|
||||
Pixels=(VMemType*)palette;
|
||||
SetPlayersPalette();
|
||||
}
|
||||
|
||||
/**
|
||||
** Set the system hardware palette from an independend Palette struct.
|
||||
**
|
||||
** @param palette System independ palette structure.
|
||||
*/
|
||||
global void VideoCreatePalette(const Palette* palette)
|
||||
{
|
||||
VMemType* temp;
|
||||
|
||||
temp = VideoCreateNewPalette(palette);
|
||||
|
||||
VideoSetPalette(temp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Video initialize.
|
||||
*/
|
||||
global void InitVideo(void)
|
||||
{
|
||||
if( UseSdl ) {
|
||||
InitVideoSdl();
|
||||
} else if( UseX11 ) {
|
||||
InitVideoX11();
|
||||
} else if( UseSVGALib ) {
|
||||
InitVideoSVGA();
|
||||
} else if( UseWin32 ) {
|
||||
InitVideoWin32();
|
||||
} else {
|
||||
IfDebug( abort(); );
|
||||
}
|
||||
|
||||
//
|
||||
// Init video sub modules
|
||||
//
|
||||
InitGraphic();
|
||||
InitLineDraw();
|
||||
#ifdef NEW_VIDEO
|
||||
InitSprite();
|
||||
InitCursor();
|
||||
switch( VideoDepth ) {
|
||||
case 8: ColorCycle=ColorCycle8 ; break;
|
||||
case 15:
|
||||
case 16: ColorCycle=ColorCycle16; break;
|
||||
case 24: ColorCycle=ColorCycle24; break;
|
||||
case 32: ColorCycle=ColorCycle32; break;
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugLevel3(__FUNCTION__": %d %d\n",MapWidth,MapHeight);
|
||||
}
|
||||
|
||||
//@}
|
|
@ -40,7 +40,6 @@
|
|||
#include "interface.h"
|
||||
#include "network.h"
|
||||
#include "ui.h"
|
||||
#include "new_video.h"
|
||||
#include "sound_server.h"
|
||||
#include "sound.h"
|
||||
|
||||
|
@ -52,26 +51,6 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Architecture-dependant videomemory. Set by GameInitDisplay.
|
||||
*/
|
||||
global void* VideoMemory;
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by GameInitDisplay.
|
||||
**
|
||||
** @see GameInitDisplay
|
||||
*/
|
||||
global int VideoDepth;
|
||||
|
||||
global VMemType8 * Pixels8; /// 8 bpp palette FIXME: remove pointer
|
||||
global VMemType16 * Pixels16; /// 16 bpp palette
|
||||
global VMemType32 * Pixels32; /// 32 bpp palette
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -80,13 +59,6 @@ global VMemType32 * Pixels32; /// 32 bpp palette
|
|||
-- Sync
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
global int VideoSyncSpeed=100; // 0 disable interrupts
|
||||
volatile int VideoInterrupts; // be happy, were are quicker
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Called from SIGALRM.
|
||||
*/
|
||||
|
@ -601,11 +573,7 @@ global void WaitEventsAndKeepSync(void)
|
|||
**
|
||||
** @returns A hardware dependend pixel table.
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
global VMemType* VideoCreateNewPalette(const Palette *palette)
|
||||
#else
|
||||
global GraphicData* VideoCreateNewPalette(const Palette *palette)
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
void* pixels;
|
||||
|
@ -680,113 +648,6 @@ global GraphicData* VideoCreateNewPalette(const Palette *palette)
|
|||
return pixels;
|
||||
}
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Color cycle.
|
||||
*/
|
||||
global void ColorCycle(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
|
||||
// FIXME: this isn't 100% correct
|
||||
// Color cycling info - forest:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 48-56 cycle (water-coast boundary)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - swamp:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 4 pulsates red (Circle of Power)
|
||||
// 5-9 cycle (Runestone, Dark Portal)
|
||||
// 38-47 cycle (water)
|
||||
// 88-95 cycle (waterholes in coast and ground)
|
||||
// 240-244 cycle (water around ships)
|
||||
// Color cycling info - wasteland:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 64-70 cycle (coast)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - winter:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 40-47 cycle (water)
|
||||
// 48-54 cycle (half-sunken ice-floe)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 205-207 cycle (lights on christmas tree)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
|
||||
// FIXME: function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
x = ((VMemType8*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType8*)TheMap.TileData->Pixels)[i] = ((VMemType8*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType8*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
x=Pixels8[38];
|
||||
for( i=38; i<47; ++i ) {
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[47]=x;
|
||||
|
||||
x=Pixels8[240];
|
||||
for( i=240; i<244; ++i ) {
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[244]=x;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
x = ((VMemType16*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType16*)TheMap.TileData->Pixels)[i] = ((VMemType16*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType16*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
x=Pixels16[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[47]=x;
|
||||
|
||||
x=Pixels16[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[244]=x;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
x = ((VMemType32*)TheMap.TileData->Pixels)[38];
|
||||
for(i = 38; i < 47; ++i){
|
||||
((VMemType32*)TheMap.TileData->Pixels)[i] = ((VMemType32*)TheMap.TileData->Pixels)[i+1];
|
||||
}
|
||||
((VMemType32*)TheMap.TileData->Pixels)[47] = x;
|
||||
|
||||
x=Pixels32[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[47]=x;
|
||||
|
||||
x=Pixels32[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[244]=x;
|
||||
break;
|
||||
}
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Check video interrupt.
|
||||
**
|
||||
|
|
|
@ -17,9 +17,16 @@
|
|||
|
||||
//@{
|
||||
|
||||
#ifdef USE_SVGALIB
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
|
||||
#ifdef USE_SVGALIB
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
@ -31,7 +38,6 @@
|
|||
#include <vgamouse.h>
|
||||
#include <vgakeyboard.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
#include "video.h"
|
||||
#include "tileset.h"
|
||||
#include "sound_id.h"
|
||||
|
@ -52,52 +58,37 @@
|
|||
#include "ui.h"
|
||||
#include "new_video.h"
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Architecture-dependant videomemory. Set by GameInitDisplay.
|
||||
*/
|
||||
global void* VideoMemory;
|
||||
|
||||
/**
|
||||
** Architecture-dependant video depth. Set by GameInitDisplay.
|
||||
**
|
||||
** @see GameInitDisplay
|
||||
*/
|
||||
global int VideoDepth;
|
||||
|
||||
global VMemType8 * Pixels8; /// 8 bpp palette FIXME: remove pointer
|
||||
global VMemType16 * Pixels16; /// 16 bpp palette
|
||||
global VMemType32 * Pixels32; /// 32 bpp palette
|
||||
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
local int old_button; /// FIXME: docu?
|
||||
local int mouse_x; /// FIXME: docu?
|
||||
local int mouse_y; /// FIXME: docu?
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Forwards
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// FIXME: docu?
|
||||
local void MouseEvent(int button,int dx,int dy,int dz,int drx,int dry,int drz);
|
||||
/// FIXME: docu?
|
||||
local void KeyboardEvent(int scancode,int press);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Sync
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
global int VideoSyncSpeed=100; // 0 disable interrupts
|
||||
volatile int VideoInterrupts; // be happy, were are quicker
|
||||
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Sync
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Called from SIGALRM.
|
||||
*/
|
||||
local void VideoSyncHandler(int unused)
|
||||
{
|
||||
DebugLevel3("Interrupt\n");
|
||||
DebugLevel3Fn("Interrupt\n");
|
||||
++VideoInterrupts;
|
||||
}
|
||||
|
||||
|
@ -129,7 +120,7 @@ global void SetVideoSync(void)
|
|||
fprintf(stderr,"Can't set itimer\n");
|
||||
}
|
||||
|
||||
// DebugLevel1("Timer installed\n");
|
||||
DebugLevel3Fn("Timer installed\n");
|
||||
}
|
||||
|
||||
local void CloseDisplay(void)
|
||||
|
@ -330,27 +321,27 @@ global void Invalidate(void)
|
|||
*/
|
||||
local void MouseEvent(int button, int dx, int dy, int dz, int drx, int dry, int drz) {
|
||||
if((old_button == 0) && (button == MOUSE_LEFTBUTTON)) {
|
||||
DebugLevel3("first down\n");
|
||||
DebugLevel3Fn("first down\n");
|
||||
HandleButtonDown(1);
|
||||
}
|
||||
if((old_button == 0) && (button == (MOUSE_LEFTBUTTON + MOUSE_RIGHTBUTTON))) {
|
||||
DebugLevel3("second down\n");
|
||||
DebugLevel3Fn("second down\n");
|
||||
HandleButtonDown(2);
|
||||
}
|
||||
if((old_button == 0) && (button == MOUSE_RIGHTBUTTON)) {
|
||||
DebugLevel3("third down\n");
|
||||
DebugLevel3Fn("third down\n");
|
||||
HandleButtonDown(3);
|
||||
}
|
||||
if((old_button == MOUSE_LEFTBUTTON) && (button == 0)) {
|
||||
DebugLevel3("first up\n");
|
||||
DebugLevel3Fn("first up\n");
|
||||
HandleButtonUp(1);
|
||||
}
|
||||
if((old_button == (MOUSE_LEFTBUTTON + MOUSE_RIGHTBUTTON)) && (button == 0)) {
|
||||
DebugLevel3("second up\n");
|
||||
DebugLevel3Fn("second up\n");
|
||||
HandleButtonUp(2);
|
||||
}
|
||||
if((old_button == MOUSE_RIGHTBUTTON) && (button == 0)) {
|
||||
DebugLevel3("third up\n");
|
||||
DebugLevel3Fn("third up\n");
|
||||
HandleButtonUp(3);
|
||||
}
|
||||
old_button = button;
|
||||
|
@ -968,21 +959,11 @@ global void WaitEventsAndKeepSync(void)
|
|||
**
|
||||
** @returns A hardware dependend pixel table.
|
||||
*/
|
||||
#ifdef NEW_VIDEO
|
||||
global VMemType* VideoCreateNewPalette(const Palette *palette)
|
||||
#else
|
||||
global GraphicData * VideoCreateNewPalette(const Palette *palette)
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
void* pixels;
|
||||
|
||||
/*
|
||||
if( !Screen ) { // no init
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
pixels=malloc(256*sizeof(VMemType8));
|
||||
|
@ -992,11 +973,14 @@ global GraphicData * VideoCreateNewPalette(const Palette *palette)
|
|||
pixels=malloc(256*sizeof(VMemType16));
|
||||
break;
|
||||
case 24:
|
||||
// pixels=malloc(256*sizeof(VMemType24));
|
||||
// break;
|
||||
// FIXME: real 24bpp
|
||||
case 32:
|
||||
pixels=malloc(256*sizeof(VMemType32));
|
||||
break;
|
||||
default:
|
||||
DebugLevel0(__FUNCTION__": Unknown depth\n");
|
||||
DebugLevel0Fn("Unknown depth\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1047,102 +1031,13 @@ global GraphicData * VideoCreateNewPalette(const Palette *palette)
|
|||
case 32:
|
||||
// FIXME: write this please
|
||||
default:
|
||||
DebugLevel0(__FUNCTION__": Depth not written\n");
|
||||
DebugLevel0Fn("Depth not written\n");
|
||||
}
|
||||
}
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
#ifndef NEW_VIDEO
|
||||
|
||||
/**
|
||||
** Color cycle.
|
||||
*/
|
||||
global void ColorCycle(void)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
|
||||
// FIXME: this isn't 100% correct
|
||||
// Color cycling info - forest:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 48-56 cycle (water-coast boundary)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - swamp:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 4 pulsates red (Circle of Power)
|
||||
// 5-9 cycle (Runestone, Dark Portal)
|
||||
// 38-47 cycle (water)
|
||||
// 88-95 cycle (waterholes in coast and ground)
|
||||
// 240-244 cycle (water around ships)
|
||||
// Color cycling info - wasteland:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 38-47 cycle (water)
|
||||
// 64-70 cycle (coast)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
// Color cycling info - winter:
|
||||
// 3 flash red/green (attacked building on minimap)
|
||||
// 40-47 cycle (water)
|
||||
// 48-54 cycle (half-sunken ice-floe)
|
||||
// 202 pulsates red (Circle of Power)
|
||||
// 205-207 cycle (lights on christmas tree)
|
||||
// 240-244 cycle (water around ships, Runestone, Dark Portal)
|
||||
|
||||
// FIXME: function pointer
|
||||
switch( VideoDepth ) {
|
||||
case 8:
|
||||
x=Pixels8[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[47]=x;
|
||||
|
||||
x=Pixels8[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels8[i]=Pixels8[i+1];
|
||||
}
|
||||
Pixels8[244]=x;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
x=Pixels16[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[47]=x;
|
||||
|
||||
x=Pixels16[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels16[i]=Pixels16[i+1];
|
||||
}
|
||||
Pixels16[244]=x;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
x=Pixels32[38];
|
||||
for( i=38; i<47; ++i ) { // tileset color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[47]=x;
|
||||
|
||||
x=Pixels32[240];
|
||||
for( i=240; i<244; ++i ) { // units/icons color cycle
|
||||
Pixels32[i]=Pixels32[i+1];
|
||||
}
|
||||
Pixels32[244]=x;
|
||||
break;
|
||||
}
|
||||
|
||||
MapColorCycle(); // FIXME: could be little more informativer
|
||||
MustRedraw|=RedrawMap|RedrawInfoPanel;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Check video interrupt.
|
||||
**
|
||||
|
@ -1151,7 +1046,7 @@ global void ColorCycle(void)
|
|||
global void CheckVideoInterrupts(void)
|
||||
{
|
||||
if( VideoInterrupts ) {
|
||||
//DebugLevel1("Slow frame\n");
|
||||
//DebugLevel1Fn("Slow frame\n");
|
||||
IfDebug(
|
||||
DrawText(TheUI.MapX+10,TheUI.MapY+10,GameFont,"SLOW FRAME!!");
|
||||
);
|
||||
|
|
1987
src/video/video.cpp
1987
src/video/video.cpp
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue