* svn properties 2nd try

This commit is contained in:
tlh2000 2009-05-30 13:01:25 +00:00
parent 2029496913
commit 2e59e25ff4
11 changed files with 145 additions and 145 deletions

View file

@ -325,4 +325,4 @@ msgid "%s attacked"
msgstr "%s attackeras" msgstr "%s attackeras"

View file

@ -1,10 +1,10 @@
/* _______ __ __ __ ______ __ __ _______ __ __ /* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
* *
* Copyright (c) 2004, 2005 darkbits Js_./ * Copyright (c) 2004, 2005 darkbits Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa * Per Larsson a.k.a finalman _RqZ{a<^_aa

View file

@ -1,9 +1,9 @@
// ____ _ __ // ____ _ __
// / __ )____ _____ | | / /___ ___________ // / __ )____ _____ | | / /___ ___________
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
// /_____/\____/____/ |__/|__/\__,_/_/ /____/ // /_____/\____/____/ |__/|__/\__,_/_/ /____/
// //
// A futuristic real-time strategy game. // A futuristic real-time strategy game.
// This file is part of Bos Wars. // This file is part of Bos Wars.
// //

View file

@ -180,7 +180,7 @@ public:
void add(CParticle *particle); void add(CParticle *particle);
void clear(); void clear();
CPosition getScreenPos(const CPosition &pos); CPosition getScreenPos(const CPosition &pos);
inline void setLowDetail(bool detail) { lowDetail = detail; } inline void setLowDetail(bool detail) { lowDetail = detail; }

View file

@ -173,23 +173,23 @@ public:
#ifdef DEBUG #ifdef DEBUG
unsigned int TilesetTile; /// tileset tile number unsigned int TilesetTile; /// tileset tile number
#endif #endif
/// Check if a field for the user is explored. /// Check if a field for the user is explored.
bool IsExplored(const unsigned int player_index) const bool IsExplored(const unsigned int player_index) const
//bool IsExplored(const CPlayer *const player, bool NoFogOfWar = false) const //bool IsExplored(const CPlayer *const player, bool NoFogOfWar = false) const
{ {
//return IsTileVisible(player, index) > 0; //return IsTileVisible(player, index) > 0;
#if 1 #if 1
//return !!Visible[player->Index]; //return !!Visible[player->Index];
return !!Visible[player_index]; return !!Visible[player_index];
#else #else
if(!Visible[player->Index]) if(!Visible[player->Index])
return !!IsVisible(player, NoFogOfWar); return !!IsVisible(player, NoFogOfWar);
return true; return true;
#endif #endif
}; };
}; };

View file

@ -51,7 +51,7 @@ struct CUnitCache {
std::vector<CUnit *> Units; std::vector<CUnit *> Units;
CUnitCache() : Units() { Units.clear();} CUnitCache() : Units() { Units.clear();}
inline size_t size() const inline size_t size() const
{ {
return Units.size(); return Units.size();
@ -94,18 +94,18 @@ struct CUnitCache {
int n = (size+3)/4; int n = (size+3)/4;
const CUnit **cache = (const CUnit **)Units.data(); const CUnit **cache = (const CUnit **)Units.data();
switch (size & 3) { switch (size & 3) {
case 0: case 0:
do { do {
unit = *cache; unit = *cache;
if(pred(unit)) if(pred(unit))
return (CUnit *)unit; return (CUnit *)unit;
cache++; cache++;
case 3: case 3:
unit = *cache; unit = *cache;
if(pred(unit)) if(pred(unit))
return (CUnit *)unit; return (CUnit *)unit;
cache++; cache++;
case 2: case 2:
unit = *cache; unit = *cache;
if(pred(unit)) if(pred(unit))
return (CUnit *)unit; return (CUnit *)unit;
@ -119,7 +119,7 @@ struct CUnitCache {
} }
} }
return NULL; return NULL;
#endif #endif
} }
/** /**
@ -129,10 +129,10 @@ struct CUnitCache {
* *
* Applies the function object @p f to each element in the cache. * Applies the function object @p f to each element in the cache.
* @p functor must not modify the order of the cache. * @p functor must not modify the order of the cache.
*/ */
template<typename _T> template<typename _T>
inline void for_each(_T &functor) inline void for_each(_T &functor)
{ {
const size_t size = Units.size(); const size_t size = Units.size();
#if __GNUC__ < 4 #if __GNUC__ < 4
for(unsigned int i = 0; i < size; ++i) for(unsigned int i = 0; i < size; ++i)
@ -143,7 +143,7 @@ struct CUnitCache {
int n = (size+3)/4; int n = (size+3)/4;
CUnit **cache = (CUnit **)Units.data(); CUnit **cache = (CUnit **)Units.data();
switch (size & 3) { switch (size & 3) {
case 0: do { case 0: do {
functor(*cache++); functor(*cache++);
case 3: functor(*cache++); case 3: functor(*cache++);
case 2: functor(*cache++); case 2: functor(*cache++);
@ -162,35 +162,35 @@ struct CUnitCache {
* Applies the function object @p f to each element in the cache. * Applies the function object @p f to each element in the cache.
* @p functor must not modify the order of the cache. * @p functor must not modify the order of the cache.
* If @p functor return false then loop is exited. * If @p functor return false then loop is exited.
*/ */
template<typename _T> template<typename _T>
inline int for_each_if(_T &functor) inline int for_each_if(_T &functor)
{ {
const size_t size = Units.size(); const size_t size = Units.size();
int count = 0; int count = 0;
#ifdef _MSC_VER #ifdef _MSC_VER
while(size && functor(Units[count]) && ++count < size); while(size && functor(Units[count]) && ++count < size);
#else #else
if(size) { if(size) {
int n = (size+3)/4; int n = (size+3)/4;
switch (size & 3) { switch (size & 3) {
case 0: case 0:
do { do {
if(!functor(Units[count])) if(!functor(Units[count]))
return count; return count;
count++; count++;
case 3: case 3:
if(!functor(Units[count])) if(!functor(Units[count]))
return count; return count;
count++; count++;
case 2: case 2:
if(!functor(Units[count])) if(!functor(Units[count]))
return count; return count;
count++; count++;
case 1: case 1:
if(!functor(Units[count])) if(!functor(Units[count]))
return count ; return count ;
count++; count++;
} while ( --n > 0 ); } while ( --n > 0 );
} }
} }
@ -204,7 +204,7 @@ struct CUnitCache {
** **
** @param index Unit index to remove from container. ** @param index Unit index to remove from container.
** @return pointer to removed element. ** @return pointer to removed element.
*/ */
inline CUnit * Remove(const unsigned int index) inline CUnit * Remove(const unsigned int index)
{ {
const size_t size = Units.size(); const size_t size = Units.size();
@ -216,15 +216,15 @@ struct CUnitCache {
Units.pop_back(); Units.pop_back();
return tmp; return tmp;
} }
/** /**
** Remove unit from unit cache. ** Remove unit from unit cache.
** **
** @param unit Unit pointer to remove from container. ** @param unit Unit pointer to remove from container.
*/ */
inline bool Remove(CUnit *const unit) inline bool Remove(CUnit *const unit)
{ {
#ifndef SECURE_UNIT_REMOVING #ifndef SECURE_UNIT_REMOVING
const size_t size = Units.size(); const size_t size = Units.size();
if(size == 1 && unit == Units[0]) { if(size == 1 && unit == Units[0]) {
Units.pop_back(); Units.pop_back();
@ -238,7 +238,7 @@ struct CUnitCache {
return true; return true;
} }
} }
} }
#else #else
for(std::vector<CUnit *>::iterator i(Units.begin()), end(Units.end()); for(std::vector<CUnit *>::iterator i(Units.begin()), end(Units.end());
i != end; ++i) { i != end; ++i) {
@ -255,7 +255,7 @@ struct CUnitCache {
** Remove unit from unit cache. ** Remove unit from unit cache.
** **
** @param unit Unit pointer to remove from container. ** @param unit Unit pointer to remove from container.
*/ */
inline void RemoveS(CUnit *const unit) inline void RemoveS(CUnit *const unit)
{ {
for(std::vector<CUnit *>::iterator i(Units.begin()), end(Units.end()); for(std::vector<CUnit *>::iterator i(Units.begin()), end(Units.end());
@ -266,7 +266,7 @@ struct CUnitCache {
} }
} }
} }
/** /**
** Insert new unit into tile cache. ** Insert new unit into tile cache.
** Sorted version for binary searching. ** Sorted version for binary searching.

View file

@ -44,7 +44,7 @@ static inline float deg2rad(int degrees) {
CChunkParticle::CChunkParticle(CPosition position, Animation *smokeAnimation) : CChunkParticle::CChunkParticle(CPosition position, Animation *smokeAnimation) :
CParticle(position), initialPos(position), nextSmokeTicks(0), age(0), CParticle(position), initialPos(position), nextSmokeTicks(0), age(0),
height(0.f) height(0.f)
{ {
float radians = deg2rad(MyRand() % 360); float radians = deg2rad(MyRand() % 360);
@ -76,20 +76,20 @@ void CChunkParticle::draw()
CPosition screenPos = ParticleManager.getScreenPos(pos); CPosition screenPos = ParticleManager.getScreenPos(pos);
Uint32 color = ColorBlack; Uint32 color = ColorBlack;
Video.DrawRectangleClip(color, (int)screenPos.x - 1, Video.DrawRectangleClip(color, (int)screenPos.x - 1,
(int)calculateScreenPos(screenPos.y, height) - 1, 2, 2); (int)calculateScreenPos(screenPos.y, height) - 1, 2, 2);
} }
static float getHorizontalPosition(int initialVelocity, static float getHorizontalPosition(int initialVelocity,
float trajectoryAngle, float time) float trajectoryAngle, float time)
{ {
return (initialVelocity * cos(trajectoryAngle)) * time; return (initialVelocity * cos(trajectoryAngle)) * time;
} }
static float getVerticalPosition(int initialVelocity, static float getVerticalPosition(int initialVelocity,
float trajectoryAngle, float time) float trajectoryAngle, float time)
{ {
return (initialVelocity * sin(trajectoryAngle)) * time - return (initialVelocity * sin(trajectoryAngle)) * time -
(gravity / 2.0f) * (time * time); (gravity / 2.0f) * (time * time);
} }
@ -115,7 +115,7 @@ void CChunkParticle::update(int ticks)
float time = age / 1000.f; float time = age / 1000.f;
float distance = float distance =
getHorizontalPosition(initialVelocity, trajectoryAngle, time); getHorizontalPosition(initialVelocity, trajectoryAngle, time);
pos.x = initialPos.x + distance * direction.x; pos.x = initialPos.x + distance * direction.x;
pos.y = initialPos.y + distance * direction.y; pos.y = initialPos.y + distance * direction.y;

View file

@ -1,9 +1,9 @@
// ____ _ __ // ____ _ __
// / __ )____ _____ | | / /___ ___________ // / __ )____ _____ | | / /___ ___________
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
// /_____/\____/____/ |__/|__/\__,_/_/ /____/ // /_____/\____/____/ |__/|__/\__,_/_/ /____/
// //
// A futuristic real-time strategy game. // A futuristic real-time strategy game.
// This file is part of Bos Wars. // This file is part of Bos Wars.
// //

View file

@ -280,7 +280,7 @@ CUnit *CanBuildHere(const CUnit *unit, const CUnitType *type, int x, int y)
const int width = type->TileWidth; const int width = type->TileWidth;
int w, h = type->TileHeight; int w, h = type->TileHeight;
bool success = false; bool success = false;
CMapField *mf; CMapField *mf;
// Need at least one coast tile // Need at least one coast tile
unsigned int index = Map.getIndex(x, y); unsigned int index = Map.getIndex(x, y);
@ -288,13 +288,13 @@ CUnit *CanBuildHere(const CUnit *unit, const CUnitType *type, int x, int y)
mf = Map.Field(index); mf = Map.Field(index);
w = width; w = width;
do { do {
//if (Map.CoastOnMap(x ,y)) { //if (Map.CoastOnMap(x ,y)) {
if((mf->Flags & MapFieldCoastAllowed) == MapFieldCoastAllowed) { if((mf->Flags & MapFieldCoastAllowed) == MapFieldCoastAllowed) {
success = true; success = true;
} }
++mf; ++mf;
} while(!success && --w); } while(!success && --w);
index += Map.Info.MapWidth; index += Map.Info.MapWidth;
} while(!success && --h); } while(!success && --h);
if (!success) { if (!success) {
return NULL; return NULL;
@ -316,8 +316,8 @@ CUnit *CanBuildHere(const CUnit *unit, const CUnitType *type, int x, int y)
} }
} }
} }
return NULL; return NULL;
} }
return (unit == NULL) ? (CUnit *)1 : const_cast<CUnit *>(unit); return (unit == NULL) ? (CUnit *)1 : const_cast<CUnit *>(unit);
} }
@ -335,7 +335,7 @@ bool CanBuildOn(int x, int y, int mask)
return (Map.Info.IsPointOnMap(x,y) && !Map.CheckMask(x, y,mask)); return (Map.Info.IsPointOnMap(x,y) && !Map.CheckMask(x, y,mask));
} }
extern int extern int
MapFogFilterFlags(CPlayer *player, const unsigned int index, int mask); MapFogFilterFlags(CPlayer *player, const unsigned int index, int mask);
/** /**
@ -388,13 +388,13 @@ CUnit *CanBuildUnitType(const CUnit *unit,
for (w = type->TileWidth; w--;) { for (w = type->TileWidth; w--;) {
/* first part of if (!CanBuildOn(x + w, y + h, testmask)) */ /* first part of if (!CanBuildOn(x + w, y + h, testmask)) */
if(!Map.Info.IsPointOnMap(x + w, y + h)) { if(!Map.Info.IsPointOnMap(x + w, y + h)) {
h = type->TileHeight; h = type->TileHeight;
ontop = NULL; ontop = NULL;
break; break;
} }
if (player && !real) { if (player && !real) {
//testmask = MapFogFilterFlags(player, x + w, y + h, type->MovementMask); //testmask = MapFogFilterFlags(player, x + w, y + h, type->MovementMask);
testmask = MapFogFilterFlags(player, testmask = MapFogFilterFlags(player,
index + x + w, type->MovementMask); index + x + w, type->MovementMask);
} else { } else {
testmask = type->MovementMask; testmask = type->MovementMask;
@ -402,12 +402,12 @@ CUnit *CanBuildUnitType(const CUnit *unit,
/*secound part of if (!CanBuildOn(x + w, y + h, testmask)) */ /*secound part of if (!CanBuildOn(x + w, y + h, testmask)) */
if(Map.CheckMask(index + x + w,testmask)) if(Map.CheckMask(index + x + w,testmask))
{ {
h = type->TileHeight; h = type->TileHeight;
ontop = NULL; ontop = NULL;
break; break;
} }
if (player && !Map.IsFieldExplored(player, index + x + w)) { if (player && !Map.IsFieldExplored(player, index + x + w)) {
h = type->TileHeight; h = type->TileHeight;
ontop = NULL; ontop = NULL;
break; break;
} }

View file

@ -165,7 +165,7 @@ void SaveOrder(const COrderPtr order, CFile *file)
case UnitActionBuild: case UnitActionBuild:
case UnitActionTransformInto: case UnitActionTransformInto:
file->printf(", \"type\", \"%s\"", order->Arg1.Type->Ident.c_str()); file->printf(", \"type\", \"%s\"", order->Arg1.Type->Ident.c_str());
break; break;
case UnitActionPatrol: case UnitActionPatrol:
file->printf(", \"patrol\", {%d, %d}", file->printf(", \"patrol\", {%d, %d}",
order->Arg1.Patrol.X, order->Arg1.Patrol.Y); order->Arg1.Patrol.X, order->Arg1.Patrol.Y);
@ -183,7 +183,7 @@ void SaveOrder(const COrderPtr order, CFile *file)
case UnitActionResource : case UnitActionResource :
case UnitActionReturnGoods : case UnitActionReturnGoods :
if (order->CurrentResource) { if (order->CurrentResource) {
file->printf(", \"current-resource\", \"%s\",", file->printf(", \"current-resource\", \"%s\",",
DefaultResourceNames[order->CurrentResource].c_str()); DefaultResourceNames[order->CurrentResource].c_str());
if(order->CurrentResource == WoodCost) { if(order->CurrentResource == WoodCost) {
file->printf(" \"resource-pos\", {%d, %d}", file->printf(" \"resource-pos\", {%d, %d}",
@ -193,8 +193,8 @@ void SaveOrder(const COrderPtr order, CFile *file)
/* this unit is destroyed so it's not in the global unit /* this unit is destroyed so it's not in the global unit
* array - this means it won't be saved!!! */ * array - this means it won't be saved!!! */
printf ("FIXME: storing destroyed Mine - loading will fail.\n"); printf ("FIXME: storing destroyed Mine - loading will fail.\n");
} }
file->printf(" \"resource-mine\", \"%s\"", file->printf(" \"resource-mine\", \"%s\"",
UnitReference(order->Arg1.Resource.Mine).c_str()); UnitReference(order->Arg1.Resource.Mine).c_str());
} }
} }
@ -365,10 +365,10 @@ void SaveUnit(const CUnit *unit, CFile *file)
* array - this means it won't be saved!!! */ * array - this means it won't be saved!!! */
printf ("FIXME: storing destroyed Worker - loading will fail.\n"); printf ("FIXME: storing destroyed Worker - loading will fail.\n");
} }
file->printf(" \"next-worker\", \"%s\",", file->printf(" \"next-worker\", \"%s\",",
UnitReference(unit->NextWorker).c_str()); UnitReference(unit->NextWorker).c_str());
} }
file->printf(" \"units-boarded-count\", %d,", unit->BoardCount); file->printf(" \"units-boarded-count\", %d,", unit->BoardCount);
if (unit->UnitInside) { if (unit->UnitInside) {
@ -416,7 +416,7 @@ void SaveUnit(const CUnit *unit, CFile *file)
* array - this means it won't be saved!!! */ * array - this means it won't be saved!!! */
printf ("FIXME: storing destroyed Worker - loading will fail.\n"); printf ("FIXME: storing destroyed Worker - loading will fail.\n");
} }
file->printf(", \"first-worker\", \"%s\"", file->printf(", \"first-worker\", \"%s\"",
UnitReference(unit->Data.Resource.Workers).c_str()); UnitReference(unit->Data.Resource.Workers).c_str());
} }
file->printf("}"); file->printf("}");

View file

@ -11,18 +11,18 @@ struct CPrimitives {
virtual void DrawLine(Uint32 color, int sx, int sy, int dx, int dy) = 0; virtual void DrawLine(Uint32 color, int sx, int sy, int dx, int dy) = 0;
virtual void DrawTransLine(Uint32 color, int sx, int sy, virtual void DrawTransLine(Uint32 color, int sx, int sy,
int dx, int dy, unsigned char alpha) = 0; int dx, int dy, unsigned char alpha) = 0;
virtual void DrawRectangle(Uint32 color, int x, int y, int w, int h) = 0; virtual void DrawRectangle(Uint32 color, int x, int y, int w, int h) = 0;
virtual void DrawTransRectangle(Uint32 color, int x, int y, virtual void DrawTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha) = 0; int w, int h, unsigned char alpha) = 0;
virtual void FillTransRectangle(Uint32 color, int x, int y, virtual void FillTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha) = 0; int w, int h, unsigned char alpha) = 0;
virtual void DrawCircle(Uint32 color, int x, int y, int r) = 0; virtual void DrawCircle(Uint32 color, int x, int y, int r) = 0;
virtual void DrawTransCircle(Uint32 color, int x, int y, virtual void DrawTransCircle(Uint32 color, int x, int y,
int r, unsigned char alpha) = 0; int r, unsigned char alpha) = 0;
virtual void FillCircle(Uint32 color, int x, int y, int r) = 0; virtual void FillCircle(Uint32 color, int x, int y, int r) = 0;
virtual void FillTransCircle(Uint32 color, int x, int y, virtual void FillTransCircle(Uint32 color, int x, int y,
int r, unsigned char alpha) = 0; int r, unsigned char alpha) = 0;
@ -60,7 +60,7 @@ static inline void PutPixel(void *const pixels,
};// __attribute__ ((nothrow,nonnull (1))); };// __attribute__ ((nothrow,nonnull (1)));
template <const int BPP> template <const int BPP>
static inline void static inline void
PutPixelDouble(void *pixels, const unsigned int index, Uint32 color) PutPixelDouble(void *pixels, const unsigned int index, Uint32 color)
{ {
if(BPP == 1) { if(BPP == 1) {
@ -88,18 +88,18 @@ PutPixelDouble(void *pixels, const unsigned int index, Uint32 color)
};// __attribute__ ((nothrow,nonnull (1))); };// __attribute__ ((nothrow,nonnull (1)));
template <const int BPP> template <const int BPP>
static inline void static inline void
PutPixelQuatro(void *pixels, unsigned int index, Uint32 color) PutPixelQuatro(void *pixels, unsigned int index, Uint32 color)
{ {
if(BPP == 1) { if(BPP == 1) {
color &= 0xFF; color &= 0xFF;
color |= color << 8; color |= color << 8;
color |= color << 16; color |= color << 16;
*((Uint32*)(((Uint8 *)pixels) + index)) = color; *((Uint32*)(((Uint8 *)pixels) + index)) = color;
} else if(BPP == 2) { } else if(BPP == 2) {
Uint32 *ptr = (Uint32*)(((Uint16 *)pixels) + index); Uint32 *ptr = (Uint32*)(((Uint16 *)pixels) + index);
color &= 0xFFFF; color &= 0xFFFF;
color |= color << 16; color |= color << 16;
#ifdef __x86_64__ #ifdef __x86_64__
Uint64 tmp = color; Uint64 tmp = color;
tmp <<= 32; tmp <<= 32;
@ -108,7 +108,7 @@ PutPixelQuatro(void *pixels, unsigned int index, Uint32 color)
#else #else
*ptr++ = color; *ptr++ = color;
*ptr = color; *ptr = color;
#endif #endif
} else if(BPP == 4) { } else if(BPP == 4) {
Uint32 *ptr = ((Uint32 *)pixels) + index; Uint32 *ptr = ((Uint32 *)pixels) + index;
#ifdef __x86_64__ #ifdef __x86_64__
@ -159,17 +159,17 @@ static inline void DrawHLine(void *pixels, unsigned int index,
--width; --width;
default: default:
break; break;
} }
#else #else
if(((uintptr_t)pixels) & BPP ) { if(((uintptr_t)pixels) & BPP ) {
PutPixel<BPP>(pixels, index, color); PutPixel<BPP>(pixels, index, color);
index++; index++;
--width; --width;
} }
#endif #endif
} }
#ifdef __x86_64__ #ifdef __x86_64__
else if(BPP == 4 && ((uintptr_t)pixels) & BPP) { else if(BPP == 4 && ((uintptr_t)pixels) & BPP) {
PutPixel<BPP>(pixels, index, color); PutPixel<BPP>(pixels, index, color);
index++; index++;
--width; --width;
@ -234,8 +234,8 @@ class CRenderer : public CPrimitives {
} else { } else {
assert(0); assert(0);
} }
} }
*p = (dp >> 16) | dp; *p = (dp >> 16) | dp;
} else if(BPP == 4) { } else if(BPP == 4) {
/* RGB888(8) */ /* RGB888(8) */
Uint32 *p = (((Uint32 *)pixels) + index); Uint32 *p = (((Uint32 *)pixels) + index);
@ -263,7 +263,7 @@ class CRenderer : public CPrimitives {
{ {
if(BPP == 2) { if(BPP == 2) {
/* /*
#ifdef __x86_64__ #ifdef __x86_64__
//FIXME //FIXME
unsigned int dp; unsigned int dp;
@ -282,53 +282,53 @@ class CRenderer : public CPrimitives {
Uint64 src1 = (src0 | (src0 << 32)); Uint64 src1 = (src0 | (src0 << 32));
Uint64 dst0 = *p; Uint64 dst0 = *p;
Uint64 dst1 = (dst0 >> 8); Uint64 dst1 = (dst0 >> 8);
src0 = src1; src0 = src1;
src1 >>= 8; src1 >>= 8;
src0 &= 0x00FF00FF00FF00FF; src0 &= 0x00FF00FF00FF00FF;
src1 &= 0x00FF00FF00FF00FF; src1 &= 0x00FF00FF00FF00FF;
dst0 &= 0x00FF00FF00FF00FF; dst0 &= 0x00FF00FF00FF00FF;
dst1 &= 0x00FF00FF00FF00FF; dst1 &= 0x00FF00FF00FF00FF;
dst0 += ((src0 - dst0) * A >> 8); dst0 += ((src0 - dst0) * A >> 8);
dst0 &= 0x00FF00FF00FF00FF; dst0 &= 0x00FF00FF00FF00FF;
dst1 += ((src1 - dst1) * A >> 8); dst1 += ((src1 - dst1) * A >> 8);
dst1 &= 0x00FF00FF00FF00FF; dst1 &= 0x00FF00FF00FF00FF;
*p = dst0 | (dst1 << 8);; *p = dst0 | (dst1 << 8);;
#else #else
Uint32 *p = (((Uint32 *)pixels) + index); Uint32 *p = (((Uint32 *)pixels) + index);
/* /*
* FIXME: * FIXME:
* Two Pixels Blend for litle endian and * Two Pixels Blend for litle endian and
* big endian may be broken. * big endian may be broken.
*/ */
unsigned int d1, s1 = color & 0xff00ff; unsigned int d1, s1 = color & 0xff00ff;
unsigned int dp = *p; unsigned int dp = *p;
d1 = dp & 0xff00ff; d1 = dp & 0xff00ff;
color &= 0xff00; color &= 0xff00;
color = (color >> 8) | (color << 8); color = (color >> 8) | (color << 8);
d1 += (s1 - d1) * alpha >> 8; d1 += (s1 - d1) * alpha >> 8;
d1 &= 0xff00ff; d1 &= 0xff00ff;
dp = ((dp & 0xff00) >> 8) | dp = ((dp & 0xff00) >> 8) |
((p[1] & 0xff00) << 8); ((p[1] & 0xff00) << 8);
dp += (color - dp) * alpha >> 8; dp += (color - dp) * alpha >> 8;
dp &= 0x00ff00ff; dp &= 0x00ff00ff;
*p++ = d1 | ((dp << 8) & 0xff00) | 0xff000000; *p++ = d1 | ((dp << 8) & 0xff00) | 0xff000000;
d1 = *p; d1 = *p;
d1 &= 0xff00ff; d1 &= 0xff00ff;
d1 += (s1 - d1) * alpha >> 8; d1 += (s1 - d1) * alpha >> 8;
d1 &= 0xff00ff; d1 &= 0xff00ff;
*p = d1 | ((dp >> 8) & 0xff00) | 0xff000000; *p = d1 | ((dp >> 8) & 0xff00) | 0xff000000;
#endif #endif
} else { } else {
@ -344,26 +344,26 @@ class CRenderer : public CPrimitives {
/* blend a single 16 bit pixel at 50% */ /* blend a single 16 bit pixel at 50% */
#define BLEND16_50(d, s, mask) \ #define BLEND16_50(d, s, mask) \
((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))
Uint16 *p = (((Uint16 *)pixels) + index); Uint16 *p = (((Uint16 *)pixels) + index);
Uint16 d = *p; Uint16 d = *p;
Uint16 s = color & 0xFFFF; // I hope that caler secure it; Uint16 s = color & 0xFFFF; // I hope that caler secure it;
*p = BLEND16_50(d, s, MASK); *p = BLEND16_50(d, s, MASK);
#undef BLEND16_50 #undef BLEND16_50
} else if(BPP == 4) { } else if(BPP == 4) {
Uint32 *p = (((Uint32 *)pixels) + index); Uint32 *p = (((Uint32 *)pixels) + index);
unsigned int d = *p; unsigned int d = *p;
*p = ((((color & 0x00fefefe) + (d & 0x00fefefe)) >> 1) *p = ((((color & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
+ (color & d & 0x00010101)) | 0xff000000; + (color & d & 0x00010101)) | 0xff000000;
} else { } else {
assert(0); assert(0);
} }
}; };
static inline void PutTransPixel128Double(void *pixels, const unsigned int index, static inline void PutTransPixel128Double(void *pixels, const unsigned int index,
const Uint32 color) const Uint32 color)
{ {
@ -372,23 +372,23 @@ class CRenderer : public CPrimitives {
#define BLEND2x16_50(d, s, mask) \ #define BLEND2x16_50(d, s, mask) \
(((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
+ (s & d & (~(mask | mask << 16)))) + (s & d & (~(mask | mask << 16))))
Uint32 *p = (Uint32 *)(((Uint16 *)pixels) + index); Uint32 *p = (Uint32 *)(((Uint16 *)pixels) + index);
Uint32 d = *p; Uint32 d = *p;
const Uint32 s = (color & 0xFFFF) | color << 16; // I hope that caler secure it; const Uint32 s = (color & 0xFFFF) | color << 16; // I hope that caler secure it;
*p = BLEND2x16_50(d, s, MASK); *p = BLEND2x16_50(d, s, MASK);
#undef BLEND2x16_50 #undef BLEND2x16_50
} else if(BPP == 4) { } else if(BPP == 4) {
Uint32 *p = (((Uint32 *)pixels) + index); Uint32 *p = (((Uint32 *)pixels) + index);
#ifdef __x86_64__ #ifdef __x86_64__
unsigned long long int d = *(unsigned long long int *)p; unsigned long long int d = *(unsigned long long int *)p;
unsigned long long int s, c = color; unsigned long long int s, c = color;
s = c | c << 32; s = c | c << 32;
c = s & 0x00fefefe00fefefe; c = s & 0x00fefefe00fefefe;
*(unsigned long long int *)p = *(unsigned long long int *)p =
(((c + (d & 0x00fefefe00fefefe)) >> 1) (((c + (d & 0x00fefefe00fefefe)) >> 1)
+ (s & d & 0x0001010100010101)) | + (s & d & 0x0001010100010101)) |
@ -404,7 +404,7 @@ class CRenderer : public CPrimitives {
#endif #endif
} else { } else {
assert(0); assert(0);
} }
} __attribute__ ((nothrow,nonnull (1))); } __attribute__ ((nothrow,nonnull (1)));
static void DrawVLine(void *pixels, const unsigned int pitch, static void DrawVLine(void *pixels, const unsigned int pitch,
@ -480,7 +480,7 @@ class CRenderer : public CPrimitives {
}; };
#ifdef __x86_64__ #ifdef __x86_64__
if(width) PutTransPixel(pixels, index, color, alpha); if(width) PutTransPixel(pixels, index, color, alpha);
#endif #endif
} __attribute__ ((nothrow,nonnull (1))); } __attribute__ ((nothrow,nonnull (1)));
static inline void DrawTransHLine(void *pixels, static inline void DrawTransHLine(void *pixels,
@ -501,7 +501,7 @@ class CRenderer : public CPrimitives {
index += x; index += x;
DRAW::PutPixel<BPP>(TheScreen->pixels, index, color); DRAW::PutPixel<BPP>(TheScreen->pixels, index, color);
}; };
void DrawTransPixel(Uint32 color, int x, int y, unsigned char alpha) void DrawTransPixel(Uint32 color, int x, int y, unsigned char alpha)
{ {
unsigned int index = TheScreen->pitch / BPP; unsigned int index = TheScreen->pitch / BPP;
@ -554,11 +554,11 @@ class CRenderer : public CPrimitives {
dy = sy; dy = sy;
sy = t; sy = t;
} }
int ylen = dy - sy; int ylen = dy - sy;
int incr; int incr;
int xlen; int xlen;
if (sx > dx) { if (sx > dx) {
xlen = sx - dx; xlen = sx - dx;
incr = -1; incr = -1;
@ -644,17 +644,17 @@ class CRenderer : public CPrimitives {
PutTransPixel128(TheScreen->pixels, x + index, color); PutTransPixel128(TheScreen->pixels, x + index, color);
DRAW::DrawHLine<BPP>(TheScreen->pixels, x + index + 1, w - 2, color); ///(x,y,w) DRAW::DrawHLine<BPP>(TheScreen->pixels, x + index + 1, w - 2, color); ///(x,y,w)
PutTransPixel128(TheScreen->pixels, x + index + w - 1, color); PutTransPixel128(TheScreen->pixels, x + index + w - 1, color);
PutTransPixel128(TheScreen->pixels, x + index + y_offset, color); PutTransPixel128(TheScreen->pixels, x + index + y_offset, color);
DRAW::DrawHLine<BPP>(TheScreen->pixels, x + index + y_offset + 1, w - 2, color); // (x, y + h - 1, w) DRAW::DrawHLine<BPP>(TheScreen->pixels, x + index + y_offset + 1, w - 2, color); // (x, y + h - 1, w)
PutTransPixel128(TheScreen->pixels, x + index + y_offset + w - 1, color); PutTransPixel128(TheScreen->pixels, x + index + y_offset + w - 1, color);
DrawVLine(TheScreen->pixels, pitch, x + index + pitch, DrawVLine(TheScreen->pixels, pitch, x + index + pitch,
h - 2, color); //(x, y + 1, h - 2) h - 2, color); //(x, y + 1, h - 2)
DrawVLine(TheScreen->pixels, pitch, x + index + w - 1 + pitch, DrawVLine(TheScreen->pixels, pitch, x + index + w - 1 + pitch,
h - 2, color); //x + w - 1, y + 1, h - 2 h - 2, color); //x + w - 1, y + 1, h - 2
}; };
void DrawTransRectangle(Uint32 color, int x, int y, void DrawTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha) int w, int h, unsigned char alpha)
{ {
@ -662,28 +662,28 @@ class CRenderer : public CPrimitives {
unsigned int index = y * pitch; unsigned int index = y * pitch;
unsigned int y_offset = (h - 1) * pitch; unsigned int y_offset = (h - 1) * pitch;
//unsigned int a = 255 - alpha; //unsigned int a = 255 - alpha;
PutTransPixel(TheScreen->pixels, x + index, color, alpha / 2); PutTransPixel(TheScreen->pixels, x + index, color, alpha / 2);
DrawTransHLine(TheScreen->pixels, x + index + 1, w - 2, color, alpha); ///(x,y,w) DrawTransHLine(TheScreen->pixels, x + index + 1, w - 2, color, alpha); ///(x,y,w)
PutTransPixel(TheScreen->pixels, x + index + w - 1, color, alpha / 2); PutTransPixel(TheScreen->pixels, x + index + w - 1, color, alpha / 2);
PutTransPixel(TheScreen->pixels, x + index + y_offset, color, alpha / 2); PutTransPixel(TheScreen->pixels, x + index + y_offset, color, alpha / 2);
DrawTransHLine(TheScreen->pixels, x + index + y_offset + 1, DrawTransHLine(TheScreen->pixels, x + index + y_offset + 1,
w - 2, color,alpha); // (x, y + h - 1, w) w - 2, color,alpha); // (x, y + h - 1, w)
PutTransPixel(TheScreen->pixels, PutTransPixel(TheScreen->pixels,
x + index + y_offset + w - 1, color, alpha / 2); x + index + y_offset + w - 1, color, alpha / 2);
DrawTransVLine(TheScreen->pixels, pitch, x + index + pitch, DrawTransVLine(TheScreen->pixels, pitch, x + index + pitch,
h - 2, color, alpha); //(x, y + 1, h - 2) h - 2, color, alpha); //(x, y + 1, h - 2)
DrawTransVLine(TheScreen->pixels, pitch, x + index + w - 1 + pitch, DrawTransVLine(TheScreen->pixels, pitch, x + index + w - 1 + pitch,
h - 2, color, alpha); //x + w - 1, y + 1, h - 2 h - 2, color, alpha); //x + w - 1, y + 1, h - 2
}; };
void FillTransRectangle(Uint32 color, int x, int y, void FillTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha) int w, int h, unsigned char alpha)
{ {
const unsigned int pitch = TheScreen->pitch / BPP; const unsigned int pitch = TheScreen->pitch / BPP;
unsigned int index = y * pitch; unsigned int index = y * pitch;
if(alpha == 128) { if(alpha == 128) {
do { do {
DrawTransHLine128(TheScreen->pixels, x + index, w, color); DrawTransHLine128(TheScreen->pixels, x + index, w, color);
@ -693,7 +693,7 @@ class CRenderer : public CPrimitives {
do { do {
DrawTransHLineNon128(TheScreen->pixels, x + index, w, color, alpha); DrawTransHLineNon128(TheScreen->pixels, x + index, w, color, alpha);
index += pitch; index += pitch;
} while(--h); } while(--h);
} }
}; };
@ -712,7 +712,7 @@ class CRenderer : public CPrimitives {
DRAW::PutPixel<BPP>(TheScreen->pixels, x + px + index_minus, color); DRAW::PutPixel<BPP>(TheScreen->pixels, x + px + index_minus, color);
DRAW::PutPixel<BPP>(TheScreen->pixels, x - px + index_plus, color); DRAW::PutPixel<BPP>(TheScreen->pixels, x - px + index_plus, color);
DRAW::PutPixel<BPP>(TheScreen->pixels, x - px + index_minus, color); DRAW::PutPixel<BPP>(TheScreen->pixels, x - px + index_minus, color);
index_plus = (y + px) * pitch; index_plus = (y + px) * pitch;
index_minus = (y - px) * pitch; index_minus = (y - px) * pitch;
@ -727,9 +727,9 @@ class CRenderer : public CPrimitives {
p += 2 * (px - py) + 5; p += 2 * (px - py) + 5;
py -= 1; py -= 1;
} }
} }
}; };
void DrawTransCircle(Uint32 color, int x, int y, void DrawTransCircle(Uint32 color, int x, int y,
int r, unsigned char alpha) int r, unsigned char alpha)
{ {
@ -746,7 +746,7 @@ class CRenderer : public CPrimitives {
PutTransPixel(TheScreen->pixels, x + px + index_minus, color,alpha); PutTransPixel(TheScreen->pixels, x + px + index_minus, color,alpha);
PutTransPixel(TheScreen->pixels, x - px + index_plus, color,alpha); PutTransPixel(TheScreen->pixels, x - px + index_plus, color,alpha);
PutTransPixel(TheScreen->pixels, x - px + index_minus, color,alpha); PutTransPixel(TheScreen->pixels, x - px + index_minus, color,alpha);
index_plus = (y + px) * pitch; index_plus = (y + px) * pitch;
index_minus = (y - px) * pitch; index_minus = (y - px) * pitch;
@ -775,14 +775,14 @@ class CRenderer : public CPrimitives {
//FIXME: Change it to DrawHLine for speed. //FIXME: Change it to DrawHLine for speed.
unsigned int y_index = y * pitch; unsigned int y_index = y * pitch;
unsigned int py_index = py * pitch; unsigned int py_index = py * pitch;
// Fill up the middle half of the circle // Fill up the middle half of the circle
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x + px + y_index, x + px + y_index,
py + 1, color); py + 1, color);
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x + px + (y_index - py_index), x + px + (y_index - py_index),
py, color); py, color);
if (px) { if (px) {
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
@ -790,7 +790,7 @@ class CRenderer : public CPrimitives {
py + 1, color); py + 1, color);
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x - px + (y_index - py_index), x - px + (y_index - py_index),
py, color); py, color);
} }
if (p < 0) { if (p < 0) {
@ -806,18 +806,18 @@ class CRenderer : public CPrimitives {
px + 1, color); px + 1, color);
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x + py + 1 + (y_index - px_index), x + py + 1 + (y_index - px_index),
px, color); px, color);
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x - py - 1 + y_index, x - py - 1 + y_index,
px + 1, color); px + 1, color);
DrawVLine(TheScreen->pixels, pitch, DrawVLine(TheScreen->pixels, pitch,
x - py - 1 + (y_index - px_index), x - py - 1 + (y_index - px_index),
px, color); px, color);
} }
} }
} }
}; };
void FillTransCircle(Uint32 color, int x, int y, void FillTransCircle(Uint32 color, int x, int y,
int r, unsigned char alpha) int r, unsigned char alpha)
{ {
@ -830,7 +830,7 @@ class CRenderer : public CPrimitives {
//FIXME: Change it to DrawTransHLine for speed. //FIXME: Change it to DrawTransHLine for speed.
unsigned int y_index = y * pitch; unsigned int y_index = y * pitch;
unsigned int py_index = py * pitch; unsigned int py_index = py * pitch;
// Fill up the middle half of the circle // Fill up the middle half of the circle
DrawTransVLine(TheScreen->pixels, pitch, DrawTransVLine(TheScreen->pixels, pitch,
x + px + y_index, x + px + y_index,
@ -872,7 +872,7 @@ class CRenderer : public CPrimitives {
} }
} }
}; };
}; };
typedef CRenderer<2,0xfbde> Primitive16_555_t; typedef CRenderer<2,0xfbde> Primitive16_555_t;