forked from Mirrors/openclonk
Removed unused functions from Standard.{h,cpp}
Some functions that were only used from a single location were moved to the calling source files.
parent
a7812e3f3e
commit
61c63be6df
|
@ -22,6 +22,7 @@
|
|||
#ifndef INC_C4NameList
|
||||
#define INC_C4NameList
|
||||
|
||||
#include <cstring>
|
||||
class C4NameList
|
||||
{
|
||||
public:
|
||||
|
@ -38,7 +39,7 @@ class C4NameList
|
|||
public:
|
||||
bool IsEmpty();
|
||||
bool operator==(const C4NameList& rhs)
|
||||
{ return MemEqual((const uint8_t*)this,(const uint8_t*)&rhs,sizeof(C4NameList)); }
|
||||
{ return !std::memcmp((const uint8_t*)this,(const uint8_t*)&rhs,sizeof(C4NameList)); }
|
||||
void CompileFunc(StdCompiler *pComp, bool fValues = true);
|
||||
};
|
||||
|
||||
|
|
|
@ -37,11 +37,13 @@ class C4SVal
|
|||
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
|
||||
int32_t Evaluate();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
public:
|
||||
inline bool operator==(const C4SVal &rhs) const
|
||||
{
|
||||
return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator == (C4SVal Val1, C4SVal Val2)
|
||||
{ return MemEqual((void *) &Val1, (void *) &Val2, sizeof(C4SVal)); }
|
||||
|
||||
#define C4SGFXMODE_NEWGFX 1
|
||||
#define C4SGFXMODE_OLDGFX 2
|
||||
|
||||
|
|
|
@ -813,6 +813,11 @@ CSurface8 * C4MapCreatorS2::Render(const char *szMapName)
|
|||
return sfc;
|
||||
}
|
||||
|
||||
static inline void DWordAlign(int &val)
|
||||
{
|
||||
if (val%4) { val>>=2; val<<=2; val+=4; }
|
||||
}
|
||||
|
||||
BYTE *C4MapCreatorS2::RenderBuf(const char *szMapName, int32_t &sfcWdt, int32_t &sfcHgt)
|
||||
{
|
||||
// get map
|
||||
|
|
|
@ -132,6 +132,13 @@ void C4Object::DoMotion(int32_t mx, int32_t my)
|
|||
fix_x += mx; fix_y += my;
|
||||
}
|
||||
|
||||
static inline int32_t ForceLimits(int32_t &rVal, int32_t iLow, int32_t iHi)
|
||||
{
|
||||
if (rVal<iLow) { rVal=iLow; return -1; }
|
||||
if (rVal>iHi) { rVal=iHi; return +1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
void C4Object::TargetBounds(int32_t &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi)
|
||||
{
|
||||
switch (ForceLimits(ctco,limit_low,limit_hi))
|
||||
|
|
|
@ -231,6 +231,39 @@ bool C4Video::AdjustPosition()
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void StdBlit(uint8_t *bypSource, int iSourcePitch, int iSrcBufHgt,
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch, int iTrgBufHgt,
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt,
|
||||
int iBytesPerPixel=1, bool fFlip=false)
|
||||
{
|
||||
if (!bypSource || !bypTarget) return;
|
||||
if (!iTrgWdt || !iTrgHgt) return;
|
||||
int xcnt,ycnt,zcnt,sline,tline,fy;
|
||||
for (ycnt=0; ycnt<iTrgHgt; ycnt++)
|
||||
{
|
||||
fy = iSrcHgt * ycnt / iTrgHgt;
|
||||
if (iSrcBufHgt>0) sline = ( iSrcBufHgt - 1 - iSrcY - fy ) * iSourcePitch;
|
||||
else sline = ( iSrcY + fy ) * iSourcePitch;
|
||||
if (iTrgBufHgt>0) tline = ( iTrgBufHgt - 1 - iTrgY - ycnt ) * iTargetPitch;
|
||||
else tline = ( iTrgY + ycnt ) * iTargetPitch;
|
||||
if (!fFlip)
|
||||
{
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
for (zcnt=0; zcnt<iBytesPerPixel; zcnt++)
|
||||
bypTarget [ tline + (iTrgX + xcnt) * iBytesPerPixel + zcnt]
|
||||
= bypSource [ sline + (iSrcX + iSrcWdt * xcnt / iTrgWdt) * iBytesPerPixel + zcnt ];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
for (zcnt=0; zcnt<iBytesPerPixel; zcnt++)
|
||||
bypTarget [ tline + (iTrgX + iTrgWdt - 1 -xcnt) * iBytesPerPixel + zcnt]
|
||||
= bypSource [ sline + (iSrcX + iSrcWdt * xcnt / iTrgWdt) * iBytesPerPixel + zcnt ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Video::RecordFrame()
|
||||
{
|
||||
// No buffer
|
||||
|
|
|
@ -27,12 +27,7 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#elif defined(_WIN32)
|
||||
#define HAVE_IO_H 1
|
||||
#define HAVE_DIRECT_H 1
|
||||
#define HAVE_SHARE_H 1
|
||||
#define HAVE_FREETYPE
|
||||
#endif //_WIN32, HAVE_CONFIG_H
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4786) // long symbol names
|
||||
|
@ -126,8 +121,6 @@ typedef __int32 intptr_t;
|
|||
# define BREAKPOINT_HERE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef _INC_WINDOWS
|
||||
|
@ -136,6 +129,7 @@ typedef __int32 intptr_t;
|
|||
#define WINVER 0x0500
|
||||
//#define _WIN32_WINNT 0x0500
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#endif
|
||||
|
@ -161,6 +155,7 @@ typedef struct {
|
|||
|
||||
unsigned long timeGetTime(void);
|
||||
|
||||
#include <strings.h>
|
||||
inline int stricmp(const char *s1, const char *s2) {
|
||||
return strcasecmp(s1, s2);
|
||||
}
|
||||
|
@ -178,9 +173,6 @@ bool LogSilent(const char *szMessage);
|
|||
BOOL LogF(const char *strMessage, ...) GNUC_FORMAT_ATTRIBUTE;
|
||||
BOOL LogSilentF(const char *strMessage, ...) GNUC_FORMAT_ATTRIBUTE;
|
||||
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
// Color triplets
|
||||
#define C4RGB(r, g, b) ((((DWORD)(r)&0xff)<<16)|(((DWORD)(g)&0xff)<<8)|((b)&0xff))
|
||||
|
||||
|
@ -196,77 +188,51 @@ template <class T> inline void Toggle(T &v) { v = !v; }
|
|||
|
||||
const double pi = 3.14159265358979323846;
|
||||
|
||||
inline void DWordAlign(int &val)
|
||||
{
|
||||
if (val%4) { val>>=2; val<<=2; val+=4; }
|
||||
}
|
||||
|
||||
inline int DWordAligned(int val)
|
||||
{
|
||||
if (val%4) { val>>=2; val<<=2; val+=4; }
|
||||
return val;
|
||||
}
|
||||
|
||||
inline int QWordAligned(int val)
|
||||
{
|
||||
if (val%8) { val>>=3; val<<=3; val+=8; }
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
inline int32_t ForceLimits(int32_t &rVal, int32_t iLow, int32_t iHi)
|
||||
{
|
||||
if (rVal<iLow) { rVal=iLow; return -1; }
|
||||
if (rVal>iHi) { rVal=iHi; return +1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2);
|
||||
int Angle(int iX1, int iY1, int iX2, int iY2);
|
||||
int Pow(int base, int exponent);
|
||||
|
||||
inline void FillMem(void *lpMem, size_t dwSize, char bValue)
|
||||
{
|
||||
memset(lpMem,bValue,dwSize);
|
||||
}
|
||||
|
||||
#include <cstring>
|
||||
inline void ZeroMem(void *lpMem, size_t dwSize)
|
||||
{
|
||||
FillMem(lpMem,dwSize,0);
|
||||
}
|
||||
|
||||
inline bool MemEqual(const void *lpMem1, const void *lpMem2, size_t dwSize)
|
||||
{
|
||||
return !memcmp(lpMem1,lpMem2,dwSize);
|
||||
std::memset(lpMem,'\0',dwSize);
|
||||
}
|
||||
|
||||
inline void MemCopy(const void *lpMem1, void *lpMem2, size_t dwSize)
|
||||
{
|
||||
memmove(lpMem2,lpMem1,dwSize);
|
||||
std::memmove(lpMem2,lpMem1,dwSize);
|
||||
}
|
||||
|
||||
bool ForLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
bool (*fnCallback)(int32_t, int32_t, int32_t), int32_t iPar=0,
|
||||
int32_t *lastx=NULL, int32_t *lasty=NULL);
|
||||
|
||||
bool PathMove(int &rX, int &rY, int iTargetX, int iTargetY, int iSteps, int &rDelta);
|
||||
|
||||
char CharCapital(char cChar);
|
||||
#include <cctype>
|
||||
inline char CharCapital(char cChar) { return std::toupper(cChar); }
|
||||
bool IsIdentifier(char cChar);
|
||||
bool IsUpperCase(char cChar);
|
||||
bool IsLowerCase(char cChar);
|
||||
bool IsWhiteSpace(char cChar);
|
||||
inline bool IsWhiteSpace(char cChar) { return !!std::isspace(cChar); }
|
||||
|
||||
int SLen(const char *sptr);
|
||||
int SLenUntil(const char *szStr, char cUntil);
|
||||
inline int SLen(const char *sptr) { return sptr?std::strlen(sptr):0; }
|
||||
inline int SLenUntil(const char *szStr, char cUntil)
|
||||
{
|
||||
if (!szStr) return 0;
|
||||
const char *end = std::strchr(szStr, cUntil);
|
||||
return end ? end-szStr : std::strlen(szStr);
|
||||
}
|
||||
|
||||
bool SEqual(const char *szStr1, const char *szStr2);
|
||||
inline bool SEqual(const char *szStr1, const char *szStr2) { return szStr1&&szStr2?!std::strcmp(szStr1,szStr2):false; }
|
||||
bool SEqual2(const char *szStr1, const char *szStr2);
|
||||
bool SEqualUntil(const char *szStr1, const char *szStr2, char cWild);
|
||||
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen=-1);
|
||||
bool SEqual2NoCase(const char *szStr1, const char *szStr2, int iLen = -1);
|
||||
|
||||
int SCompare(const char *szStr1, const char *szStr2);
|
||||
inline int SCompare(const char *szStr1, const char *szStr2) { return szStr1&&szStr2?std::strcmp(szStr1,szStr2):0; }
|
||||
|
||||
void SCopy(const char *szSource, char *sTarget, int iMaxL=-1);
|
||||
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL=-1, int iIndex=0);
|
||||
|
@ -331,40 +297,6 @@ BOOL SWildcardMatchEx(const char *szString, const char *szWildcard);
|
|||
#define DirSep "/"
|
||||
#endif
|
||||
|
||||
void BufferBlit(uint8_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt);
|
||||
|
||||
void BufferBlitDw(uint32_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint32_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt);
|
||||
|
||||
void BufferBlitAspect(uint8_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt);
|
||||
|
||||
void BufferBlitAspectDw(uint32_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint32_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt);
|
||||
|
||||
void StdBlit(uint8_t *bypSource, int iSourcePitch, int iSrcBufHgt,
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch, int iTrgBufHgt,
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt,
|
||||
int iBytesPerPixel=1, bool fFlip=false);
|
||||
|
||||
// sprintf wrapper
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#ifndef INC_StdColors
|
||||
#define INC_StdColors
|
||||
|
||||
#include <Standard.h>
|
||||
#include "Standard.h"
|
||||
#include <math.h>
|
||||
|
||||
// color definitions
|
||||
const int FTrans=-1,FWhite=0,FBlack=1,FPlayer=2,FRed=3;
|
||||
|
|
|
@ -78,44 +78,6 @@ int Pow(int base, int exponent)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool PathMove(int &rX, int &rY, int iTargetX, int iTargetY, int iSteps, int &rDelta)
|
||||
{
|
||||
int iDeltaX,iDeltaY,aincr,bincr,iDirX,iDirY,x,y;
|
||||
// No steps
|
||||
if (iSteps<=0) return false;
|
||||
// Y based
|
||||
if (Abs(iTargetX-rX)<Abs(iTargetY-rY))
|
||||
{
|
||||
iDirX=(iTargetX>rX) ? +1 : -1; iDirY=(iTargetY>rY) ? +1 : -1;
|
||||
iDeltaY=Abs(iTargetY-rY); iDeltaX=Abs(iTargetX-rX);
|
||||
if (!rDelta) rDelta=2*iDeltaX-iDeltaY;
|
||||
aincr=2*(iDeltaX-iDeltaY); bincr=2*iDeltaX; x=rX; y=rY;
|
||||
while (y!=iTargetY)
|
||||
{
|
||||
if (rDelta>=0) { x+=iDirX; rDelta+=aincr; } else rDelta+=bincr;
|
||||
y+=iDirY;
|
||||
iSteps--; if (iSteps==0) { rX=x; rY=y; return true; }
|
||||
}
|
||||
}
|
||||
// X based
|
||||
else
|
||||
{
|
||||
iDirY=(iTargetY>rY) ? +1 : -1; iDirX=(iTargetX>rX) ? +1 : -1;
|
||||
iDeltaX=Abs(iTargetX-rX); iDeltaY=Abs(iTargetY-rY);
|
||||
if (!rDelta) rDelta=2*iDeltaY-iDeltaX;
|
||||
aincr=2*(iDeltaY-iDeltaX); bincr=2*iDeltaY; x=rX; y=rY;
|
||||
while (x!=iTargetX)
|
||||
{
|
||||
if (rDelta>=0) { y+=iDirY; rDelta+=aincr; } else rDelta+=bincr;
|
||||
x+=iDirX;
|
||||
iSteps--; if (iSteps==0) { rX=x; rY=y; return true; }
|
||||
}
|
||||
}
|
||||
// Target reached (step overshoot)
|
||||
rX=x; rY=y;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ForLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
bool (*fnCallback)(int32_t, int32_t, int32_t), int32_t iPar,
|
||||
int32_t *lastx, int32_t *lasty)
|
||||
|
@ -162,15 +124,6 @@ bool ForLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
|||
|
||||
//--------------------------------- Characters ------------------------------------------
|
||||
|
||||
char CharCapital(char cChar)
|
||||
{
|
||||
if (Inside(cChar,'a','z')) return (cChar-32);
|
||||
if (cChar=='ä') return 'Ä';
|
||||
if (cChar=='ö') return 'Ö';
|
||||
if (cChar=='ü') return 'Ü';
|
||||
return cChar;
|
||||
}
|
||||
|
||||
bool IsIdentifier(char cChar)
|
||||
{
|
||||
if (Inside(cChar,'A','Z')) return true;
|
||||
|
@ -183,43 +136,8 @@ bool IsIdentifier(char cChar)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IsWhiteSpace(char cChar)
|
||||
{
|
||||
if (cChar==' ') return true;
|
||||
if (cChar==0x09) return true; // Tab
|
||||
if (cChar==0x0D) return true; // Line feed
|
||||
if (cChar==0x0A) return true; // Line feed
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsUpperCase(char cChar)
|
||||
{
|
||||
if (Inside(cChar,'A','Z')) return true;
|
||||
if (cChar=='Ä') return true;
|
||||
if (cChar=='Ö') return true;
|
||||
if (cChar=='Ü') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsLowerCase(char cChar)
|
||||
{
|
||||
if (Inside(cChar,'a','z')) return true;
|
||||
if (cChar=='ä') return true;
|
||||
if (cChar=='ö') return true;
|
||||
if (cChar=='ü') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------- Strings ------------------------------------------------
|
||||
|
||||
int SLen(const char *sptr)
|
||||
{
|
||||
int slen=0;
|
||||
if (!sptr) return 0;
|
||||
while (*sptr) { slen++; sptr++; }
|
||||
return slen;
|
||||
}
|
||||
|
||||
void SCopyL(const char *szSource, char *sTarget, int iMaxL)
|
||||
{
|
||||
if (szSource == sTarget) return;
|
||||
|
@ -257,18 +175,6 @@ void SCopyUntil(const char *szSource, char *sTarget, const char * sUntil, size_t
|
|||
sTarget[n] = 0;
|
||||
}
|
||||
|
||||
int SCompare(const char *szStr1, const char *szStr2)
|
||||
{
|
||||
if (!szStr1 || !szStr2) return false;
|
||||
return strcmp(szStr1,szStr2);
|
||||
}
|
||||
|
||||
bool SEqual(const char *szStr1, const char *szStr2)
|
||||
{
|
||||
if (!szStr1 || !szStr2) return false;
|
||||
return !strcmp(szStr1,szStr2);
|
||||
}
|
||||
|
||||
bool SEqualUntil(const char *szStr1, const char *szStr2, char cWild)
|
||||
{
|
||||
if (!szStr1 || !szStr2) return false;
|
||||
|
@ -593,13 +499,6 @@ int SClearFrontBack(char *szString, char cClear)
|
|||
return cleared;
|
||||
}
|
||||
|
||||
int SLenUntil(const char *szStr, char cUntil)
|
||||
{
|
||||
int slen;
|
||||
for (slen=0; *szStr && (*szStr!=cUntil); slen++,szStr++) {}
|
||||
return slen;
|
||||
}
|
||||
|
||||
void SNewSegment(char *szStr, const char *szSepa)
|
||||
{
|
||||
if (szStr[0]) SAppend(szSepa,szStr);
|
||||
|
@ -891,142 +790,6 @@ const char* SGetParameter(const char *strCommandLine, int iParameter, char *strT
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------- Blitting ---------------------------------------------
|
||||
|
||||
void BufferBlit(uint8_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt)
|
||||
{
|
||||
if (!bypSource || !bypTarget) return;
|
||||
if (!iTrgWdt || !iTrgHgt) return;
|
||||
int xcnt,ycnt,sline,tline,fy;
|
||||
for (ycnt=0; ycnt<iTrgHgt; ycnt++)
|
||||
{
|
||||
fy = iSrcHgt * ycnt / iTrgHgt;
|
||||
if (iSrcBufHgt>0) sline = ( iSrcBufHgt - 1 - iSrcY - fy ) * iSourcePitch;
|
||||
else sline = ( iSrcY + fy ) * iSourcePitch;
|
||||
if (iTrgBufHgt>0) tline = ( iTrgBufHgt - 1 - iTrgY - ycnt ) * iTargetPitch;
|
||||
else tline = ( iTrgY + ycnt ) * iTargetPitch;
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
bypTarget [ tline + iTrgX + xcnt ]
|
||||
= bypSource [ sline + iSrcX + iSrcWdt * xcnt / iTrgWdt ];
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBlitDw(uint32_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint32_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt)
|
||||
{
|
||||
if (!bypSource || !bypTarget) return;
|
||||
if (!iTrgWdt || !iTrgHgt) return;
|
||||
int xcnt,ycnt,sline,tline,fy;
|
||||
for (ycnt=0; ycnt<iTrgHgt; ycnt++)
|
||||
{
|
||||
fy = iSrcHgt * ycnt / iTrgHgt;
|
||||
if (iSrcBufHgt>0) sline = ( iSrcBufHgt - 1 - iSrcY - fy ) * iSourcePitch;
|
||||
else sline = ( iSrcY + fy ) * iSourcePitch;
|
||||
if (iTrgBufHgt>0) tline = ( iTrgBufHgt - 1 - iTrgY - ycnt ) * iTargetPitch;
|
||||
else tline = ( iTrgY + ycnt ) * iTargetPitch;
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
bypTarget [ tline + iTrgX + xcnt ]
|
||||
= bypSource [ sline + iSrcX + iSrcWdt * xcnt / iTrgWdt ];
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBlitAspect(uint8_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt)
|
||||
{
|
||||
int nhgt,nwdt;
|
||||
if (!iSrcWdt || !iSrcHgt) return;
|
||||
// Adjust height aspect by width aspect
|
||||
if (100*iTrgWdt/iSrcWdt<100*iTrgHgt/iSrcHgt)
|
||||
{
|
||||
nhgt=iSrcHgt*iTrgWdt/iSrcWdt;
|
||||
iTrgY+=(iTrgHgt-nhgt)/2; iTrgHgt=nhgt;
|
||||
}
|
||||
else // Adjust width aspect by height aspect
|
||||
if (100*iTrgHgt/iSrcHgt<100*iTrgWdt/iSrcWdt)
|
||||
{
|
||||
nwdt=iSrcWdt*iTrgHgt/iSrcHgt;
|
||||
iTrgX+=(iTrgWdt-nwdt)/2; iTrgWdt=nwdt;
|
||||
}
|
||||
BufferBlit(bypSource,iSourcePitch,iSrcBufHgt,
|
||||
iSrcX,iSrcY,iSrcWdt,iSrcHgt,
|
||||
bypTarget,iTargetPitch,iTrgBufHgt,
|
||||
iTrgX,iTrgY,iTrgWdt,iTrgHgt);
|
||||
}
|
||||
|
||||
void BufferBlitAspectDw(uint32_t *bypSource, int iSourcePitch,
|
||||
int iSrcBufHgt, // Positive: Bottom up
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint32_t *bypTarget, int iTargetPitch,
|
||||
int iTrgBufHgt, // Positive: Bottom up
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt)
|
||||
{
|
||||
int nhgt,nwdt;
|
||||
if (!iSrcWdt || !iSrcHgt) return;
|
||||
// Adjust height aspect by width aspect
|
||||
if (100*iTrgWdt/iSrcWdt<100*iTrgHgt/iSrcHgt)
|
||||
{
|
||||
nhgt=iSrcHgt*iTrgWdt/iSrcWdt;
|
||||
iTrgY+=(iTrgHgt-nhgt)/2; iTrgHgt=nhgt;
|
||||
}
|
||||
else // Adjust width aspect by height aspect
|
||||
if (100*iTrgHgt/iSrcHgt<100*iTrgWdt/iSrcWdt)
|
||||
{
|
||||
nwdt=iSrcWdt*iTrgHgt/iSrcHgt;
|
||||
iTrgX+=(iTrgWdt-nwdt)/2; iTrgWdt=nwdt;
|
||||
}
|
||||
BufferBlitDw(bypSource,iSourcePitch,iSrcBufHgt,
|
||||
iSrcX,iSrcY,iSrcWdt,iSrcHgt,
|
||||
bypTarget,iTargetPitch,iTrgBufHgt,
|
||||
iTrgX,iTrgY,iTrgWdt,iTrgHgt);
|
||||
|
||||
}
|
||||
|
||||
void StdBlit(uint8_t *bypSource, int iSourcePitch, int iSrcBufHgt,
|
||||
int iSrcX, int iSrcY, int iSrcWdt, int iSrcHgt,
|
||||
uint8_t *bypTarget, int iTargetPitch, int iTrgBufHgt,
|
||||
int iTrgX, int iTrgY, int iTrgWdt, int iTrgHgt,
|
||||
int iBytesPerPixel, bool fFlip)
|
||||
{
|
||||
if (!bypSource || !bypTarget) return;
|
||||
if (!iTrgWdt || !iTrgHgt) return;
|
||||
int xcnt,ycnt,zcnt,sline,tline,fy;
|
||||
for (ycnt=0; ycnt<iTrgHgt; ycnt++)
|
||||
{
|
||||
fy = iSrcHgt * ycnt / iTrgHgt;
|
||||
if (iSrcBufHgt>0) sline = ( iSrcBufHgt - 1 - iSrcY - fy ) * iSourcePitch;
|
||||
else sline = ( iSrcY + fy ) * iSourcePitch;
|
||||
if (iTrgBufHgt>0) tline = ( iTrgBufHgt - 1 - iTrgY - ycnt ) * iTargetPitch;
|
||||
else tline = ( iTrgY + ycnt ) * iTargetPitch;
|
||||
if (!fFlip)
|
||||
{
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
for (zcnt=0; zcnt<iBytesPerPixel; zcnt++)
|
||||
bypTarget [ tline + (iTrgX + xcnt) * iBytesPerPixel + zcnt]
|
||||
= bypSource [ sline + (iSrcX + iSrcWdt * xcnt / iTrgWdt) * iBytesPerPixel + zcnt ];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xcnt=0; xcnt<iTrgWdt; xcnt++)
|
||||
for (zcnt=0; zcnt<iBytesPerPixel; zcnt++)
|
||||
bypTarget [ tline + (iTrgX + iTrgWdt - 1 -xcnt) * iBytesPerPixel + zcnt]
|
||||
= bypSource [ sline + (iSrcX + iSrcWdt * xcnt / iTrgWdt) * iBytesPerPixel + zcnt ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------- Global variables used by StdRandom -------------------------------
|
||||
|
||||
/* extern */ int RandomCount = 0;
|
||||
|
|
Loading…
Reference in New Issue