Add rayman2 source files
This commit is contained in:
120
Rayman_X/cpa/tempgrp/TDE/TDE.DSP
Normal file
120
Rayman_X/cpa/tempgrp/TDE/TDE.DSP
Normal file
@@ -0,0 +1,120 @@
|
||||
# Microsoft Developer Studio Project File - Name="TDE" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=TDE - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Tde.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Tde.mak" CFG="TDE - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "TDE - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "TDE - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""$/cpa/tempgrp/TDE", VPEAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "TDE - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "X:\CPA\Lib"
|
||||
# PROP Intermediate_Dir "Tmp\Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /G5 /MD /W3 /GX /O2 /I "X:\CPA\Public" /I "t:\dxsdk\sdk\inc" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "VISUAL" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"X:\CPA\Lib\TDEP5_vr.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "TDE - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 2
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "X:\CPA\Lib"
|
||||
# PROP Intermediate_Dir "Tmp\Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /G5 /MD /W3 /GX /Z7 /Od /I "X:\CPA\Public" /I "t:\dxsdk\sdk\inc" /D "_DEBUG" /D "_AFXDLL" /D "WIN32" /D "_WINDOWS" /D "VISUAL" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"X:\Cpa\Lib\TDEP5_vd.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "TDE - Win32 Release"
|
||||
# Name "TDE - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_draw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_dtext.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_files.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_Hierarchy.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_init.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_Lines.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_matrix.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_pick.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_rect.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tde_VOP1616.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
5
Rayman_X/cpa/tempgrp/TDE/mssccprj.scc
Normal file
5
Rayman_X/cpa/tempgrp/TDE/mssccprj.scc
Normal file
@@ -0,0 +1,5 @@
|
||||
SCC = This is a Source Code Control file
|
||||
|
||||
[TDE.DSP]
|
||||
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
|
||||
SCC_Project_Name = "$/CPA/tempgrp/TDE", NLRAAAAA
|
95
Rayman_X/cpa/tempgrp/TDE/tde_Hierarchy.c
Normal file
95
Rayman_X/cpa/tempgrp/TDE/tde_Hierarchy.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/**************************************************************************************
|
||||
|
||||
File : HIERARCHY.CPP
|
||||
Author : Delattre Franck & Val<61>rie Cluzel
|
||||
Last update : 28 August 1996
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
#include "TDE.h"
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitZList
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Initialize the Z List
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitZList(TDE_p_stSuperObject *ZList)
|
||||
{
|
||||
short i;
|
||||
|
||||
for (i=0; i<TDE_kMAXPRIORITY; i++)
|
||||
{
|
||||
ZList[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vBuildModifiedMatrix
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Calculate the modified matrix
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vBuildModifiedMatrix(TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
p_stSuperObject->stModifiedMatrix = MatrixStack[MS_Position];
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vBuildHierarchy
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Build the hierarchy by building modified matrix
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vBuildHierarchy(TDE_tdsSuperObject *p_stSuperObject, TDE_p_stSuperObject *ZList)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectInter;
|
||||
static int iPos=0;
|
||||
|
||||
// Test if priority exceeds bounds
|
||||
if (p_stSuperObject->sPriority >= TDE_kMAXPRIORITY)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningPriorityTooHigh,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
p_stSuperObject->sPriority = TDE_kMAXPRIORITY - 1;
|
||||
}
|
||||
// Fill Z list
|
||||
if (ZList[p_stSuperObject->sPriority]==NULL)
|
||||
{
|
||||
ZList[p_stSuperObject->sPriority] = p_stSuperObject;
|
||||
p_stSuperObject->p_stNextZList = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_stSuperObjectInter = ZList[p_stSuperObject->sPriority];
|
||||
while (p_stSuperObjectInter->p_stNextZList != NULL) p_stSuperObjectInter = p_stSuperObjectInter->p_stNextZList;
|
||||
p_stSuperObjectInter->p_stNextZList = p_stSuperObject;
|
||||
p_stSuperObject->p_stNextZList = NULL;
|
||||
}
|
||||
|
||||
// parse the hierarchy
|
||||
PushMatrix(&(p_stSuperObject->stMatrix));
|
||||
|
||||
TDE_vBuildModifiedMatrix(p_stSuperObject);
|
||||
if (p_stSuperObject->p_stChild != NULL)
|
||||
{
|
||||
iPos++; // Go downstairs
|
||||
for (p_stSuperObjectInter = p_stSuperObject->p_stChild; p_stSuperObjectInter!=NULL; p_stSuperObjectInter = p_stSuperObjectInter->p_stRightBrother)
|
||||
{
|
||||
TDE_vBuildHierarchy(p_stSuperObjectInter, ZList);
|
||||
PopMatrix();
|
||||
}
|
||||
iPos--; // Go upstairs
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
243
Rayman_X/cpa/tempgrp/TDE/tde_Lines.c
Normal file
243
Rayman_X/cpa/tempgrp/TDE/tde_Lines.c
Normal file
@@ -0,0 +1,243 @@
|
||||
/**************************************************************************************
|
||||
|
||||
File : LINES.CPP
|
||||
Author : Delattre Franck & Val<61>rie Cluzel
|
||||
Last update : 27 August 1996
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
#include "TDE.h"
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawLine16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Draw a line
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawLine16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
long lFirstPointX, long lFirstPointY,
|
||||
long lSecondPointX, long lSecondPointY, long lColor)
|
||||
{
|
||||
long lPitchDest, lTemp, lXIncr, lYIncr, dx, dy, lX, lY, lDecal, FirstIncr, SecondIncr;
|
||||
TDE_tdxPixel *p_usDest;
|
||||
|
||||
lPitchDest = (p_stViewAttrib->lPitch)>>1;
|
||||
p_usDest = (TDE_tdxPixel *)p_stViewAttrib->p_cVirtualScreen;
|
||||
|
||||
if (abs(lSecondPointX-lFirstPointX)<abs(lSecondPointY-lFirstPointY))
|
||||
{
|
||||
if (lFirstPointY>lSecondPointY)
|
||||
{
|
||||
lTemp=lSecondPointX; lSecondPointX=lFirstPointX; lFirstPointX=lTemp;
|
||||
lTemp=lSecondPointY; lSecondPointY=lFirstPointY; lFirstPointY=lTemp;
|
||||
}
|
||||
|
||||
lXIncr = (lSecondPointX>lFirstPointX) ? 1 : -1;
|
||||
dy = lSecondPointY-lFirstPointY;
|
||||
dx = abs(lSecondPointX-lFirstPointX);
|
||||
lDecal = 2*dx-dy;
|
||||
FirstIncr = 2*(dx-dy);
|
||||
SecondIncr = 2*dx;
|
||||
lX = lFirstPointX;
|
||||
lY = lFirstPointY;
|
||||
*(p_usDest+lPitchDest*lY+lX) = lColor;
|
||||
|
||||
for (lY=lFirstPointY+1; lY<=lSecondPointY; ++lY)
|
||||
{
|
||||
|
||||
if (lDecal>=0)
|
||||
{
|
||||
lX += lXIncr;
|
||||
lDecal += FirstIncr;
|
||||
}
|
||||
else lDecal+=SecondIncr;
|
||||
*(p_usDest+lPitchDest*lY+lX) = lColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lFirstPointX>lSecondPointX)
|
||||
{
|
||||
lTemp=lSecondPointX; lSecondPointX=lFirstPointX; lFirstPointX=lTemp;
|
||||
lTemp=lSecondPointY; lSecondPointY=lFirstPointY; lFirstPointY=lTemp;
|
||||
}
|
||||
lYIncr = (lSecondPointY>lFirstPointY) ? 1 : -1;
|
||||
dx = lSecondPointX-lFirstPointX;
|
||||
dy = abs(lSecondPointY-lFirstPointY);
|
||||
lDecal = 2*dy-dx;
|
||||
FirstIncr = 2*(dy-dx);
|
||||
SecondIncr = 2*dy;
|
||||
lX = lFirstPointX;
|
||||
lY = lFirstPointY;
|
||||
*(p_usDest+lPitchDest*lY+lX) = lColor;
|
||||
for (lX=lFirstPointX+1; lX<=lSecondPointX; ++lX)
|
||||
{
|
||||
if (lDecal>=0)
|
||||
{
|
||||
lY += lYIncr;
|
||||
lDecal += FirstIncr;
|
||||
}
|
||||
else lDecal+=SecondIncr;
|
||||
*(p_usDest+lPitchDest*lY+lX) = lColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vCalculateIntermediatePoint
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Calculate the clipped vertex between two points
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vCalculateIntermediatePoint(TDE_tdsVertex *Result_Point, TDE_tdsVertex *Point1, TDE_tdsVertex *Point2, TDE_tdxValue xValue1, TDE_tdxValue xValue2, TDE_tdxValue xInterValue)
|
||||
{
|
||||
TDE_tdxValue xRate;
|
||||
|
||||
xRate = TDE_M_Div((xInterValue-xValue2), (xValue1-xValue2));
|
||||
Result_Point->xX = Point2->xX + TDE_M_Mul((Point1->xX) - (Point2->xX), xRate);
|
||||
Result_Point->xY = Point2->xY + TDE_M_Mul((Point1->xY) - (Point2->xY), xRate);
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawSuperObjectLine16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Draw a super object line
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawSuperObjectLine16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xViewPortW, xViewPortH;
|
||||
long lFirstPointX, lFirstPointY,
|
||||
lSecondPointX, lSecondPointY;
|
||||
TDE_tdsVertex stLineCoord[2];
|
||||
|
||||
TDE_tdsLine *p_stLine = p_stSuperObject->p_stLine;
|
||||
|
||||
xViewPortW = TDE_M_LongToValue(p_stViewAttrib->dwWidth);
|
||||
xViewPortH = TDE_M_LongToValue(p_stViewAttrib->dwHeight);
|
||||
|
||||
stLineCoord[0].xX = xViewPortW * p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX;
|
||||
stLineCoord[0].xY = xViewPortH * p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY;
|
||||
|
||||
stLineCoord[1].xX = xViewPortW * p_stLine->xLength;
|
||||
stLineCoord[1].xY = 0;
|
||||
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xRxS), &stLineCoord[1], &stLineCoord[1]);
|
||||
stLineCoord[1].xX += stLineCoord[0].xX;
|
||||
stLineCoord[1].xY += stLineCoord[0].xY;
|
||||
|
||||
lFirstPointX = TDE_M_ValueToLong(stLineCoord[0].xX);
|
||||
lFirstPointY = TDE_M_ValueToLong(stLineCoord[0].xY);
|
||||
|
||||
lSecondPointX = TDE_M_ValueToLong(stLineCoord[1].xX);
|
||||
lSecondPointY = TDE_M_ValueToLong(stLineCoord[1].xY);
|
||||
|
||||
TDE_vDrawLine16(p_stViewAttrib, lFirstPointX, lFirstPointY, lSecondPointX, lSecondPointY, p_stLine->lColor);
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawSuperObjectClippedLine16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Draw a super object line with clipping
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawSuperObjectClippedLine16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xViewPortW, xViewPortH;
|
||||
|
||||
long lFirstPointX, lFirstPointY,
|
||||
lSecondPointX, lSecondPointY;
|
||||
TDE_tdsVertex stLineCoord[2];
|
||||
short si;
|
||||
|
||||
TDE_tdsLine *p_stLine = p_stSuperObject->p_stLine;
|
||||
|
||||
xViewPortW = TDE_M_LongToValue(p_stViewAttrib->dwWidth);
|
||||
xViewPortH = TDE_M_LongToValue(p_stViewAttrib->dwHeight);
|
||||
|
||||
stLineCoord[0].xX = xViewPortW * p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX;
|
||||
stLineCoord[0].xY = xViewPortH * p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY;
|
||||
|
||||
stLineCoord[1].xX = xViewPortW * p_stLine->xLength;
|
||||
stLineCoord[1].xY = 0;
|
||||
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xRxS), &stLineCoord[1], &stLineCoord[1]);
|
||||
stLineCoord[1].xX += stLineCoord[0].xX;
|
||||
stLineCoord[1].xY += stLineCoord[0].xY;
|
||||
|
||||
// X Clipping
|
||||
if ((stLineCoord[0].xX<0)&&(stLineCoord[1].xX<0)) return;
|
||||
if ((stLineCoord[0].xX>xViewPortW)&&(stLineCoord[1].xX>xViewPortW)) return;
|
||||
for (si=0; si<2; si++)
|
||||
{
|
||||
if (stLineCoord[si].xX<0)
|
||||
TDE_vCalculateIntermediatePoint(&stLineCoord[si], &stLineCoord[0], &stLineCoord[1], stLineCoord[0].xX, stLineCoord[1].xX, 0);
|
||||
}
|
||||
for (si=0; si<2; si++)
|
||||
{
|
||||
if (stLineCoord[si].xX>xViewPortW)
|
||||
TDE_vCalculateIntermediatePoint(&stLineCoord[si], &stLineCoord[0], &stLineCoord[1], stLineCoord[0].xX, stLineCoord[1].xX, xViewPortW);
|
||||
}
|
||||
|
||||
// Y Clipping
|
||||
if ((stLineCoord[0].xY<0)&&(stLineCoord[1].xY<0)) return;
|
||||
if ((stLineCoord[0].xY>xViewPortH)&&(stLineCoord[1].xY>xViewPortH)) return;
|
||||
for (si=0; si<2; si++)
|
||||
{
|
||||
if (stLineCoord[si].xY<0)
|
||||
TDE_vCalculateIntermediatePoint(&stLineCoord[si], &stLineCoord[0], &stLineCoord[1], stLineCoord[0].xY, stLineCoord[1].xY, 0);
|
||||
}
|
||||
for (si=0; si<2; si++)
|
||||
{
|
||||
if (stLineCoord[si].xY>xViewPortH)
|
||||
TDE_vCalculateIntermediatePoint(&stLineCoord[si], &stLineCoord[0], &stLineCoord[1], stLineCoord[0].xY, stLineCoord[1].xY, xViewPortH);
|
||||
}
|
||||
|
||||
lFirstPointX = TDE_M_ValueToLong(stLineCoord[0].xX);
|
||||
lFirstPointY = TDE_M_ValueToLong(stLineCoord[0].xY);
|
||||
|
||||
lSecondPointX = TDE_M_ValueToLong(stLineCoord[1].xX);
|
||||
lSecondPointY = TDE_M_ValueToLong(stLineCoord[1].xY);
|
||||
|
||||
TDE_vDrawLine16(p_stViewAttrib, lFirstPointX, lFirstPointY,
|
||||
lSecondPointX, lSecondPointY, p_stLine->lColor);
|
||||
}
|
||||
|
||||
void TDE_vDrawSuperObjectLineAbs(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xViewPortW, xViewPortH;
|
||||
long lFirstPointX, lFirstPointY,
|
||||
lSecondPointX, lSecondPointY;
|
||||
TDE_tdsVertex stLineCoord[2];
|
||||
|
||||
TDE_tdsLine *p_stLine = p_stSuperObject->p_stLine;
|
||||
|
||||
xViewPortW = TDE_M_LongToValue(p_stViewAttrib->dwWidth);
|
||||
xViewPortH = TDE_M_LongToValue(p_stViewAttrib->dwHeight);
|
||||
|
||||
stLineCoord[0].xX = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX;
|
||||
stLineCoord[0].xY = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY;
|
||||
|
||||
stLineCoord[1].xX = p_stLine->xLength;
|
||||
stLineCoord[1].xY = 0;
|
||||
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xRxS), &stLineCoord[1], &stLineCoord[1]);
|
||||
stLineCoord[1].xX += stLineCoord[0].xX;
|
||||
stLineCoord[1].xY += stLineCoord[0].xY;
|
||||
|
||||
lFirstPointX = TDE_M_ValueToLong(stLineCoord[0].xX);
|
||||
lFirstPointY = TDE_M_ValueToLong(stLineCoord[0].xY);
|
||||
|
||||
lSecondPointX = TDE_M_ValueToLong(stLineCoord[1].xX);
|
||||
lSecondPointY = TDE_M_ValueToLong(stLineCoord[1].xY);
|
||||
|
||||
TDE_vDrawLine16(p_stViewAttrib, lFirstPointX, lFirstPointY, lSecondPointX, lSecondPointY, p_stLine->lColor);
|
||||
}
|
36
Rayman_X/cpa/tempgrp/TDE/tde_VOP1616.c
Normal file
36
Rayman_X/cpa/tempgrp/TDE/tde_VOP1616.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/**************************************************
|
||||
VOP1616.CPP
|
||||
Visual basic OPerations
|
||||
for 16:16 format
|
||||
***************************************************/
|
||||
|
||||
#include "TDE.h"
|
||||
#include "TDE\TDE_VOP1616.h"
|
||||
|
||||
long TDE_MUL (long A,long B)
|
||||
{
|
||||
long retour;
|
||||
__asm{
|
||||
mov eax,A
|
||||
mov ebx,B
|
||||
imul ebx
|
||||
shrd eax,edx,16
|
||||
mov retour,eax
|
||||
}
|
||||
return retour;
|
||||
}
|
||||
|
||||
long TDE_DIV (long A,long B)
|
||||
{
|
||||
long retour;
|
||||
__asm{
|
||||
mov edx,A
|
||||
mov ebx,B
|
||||
xor eax,eax
|
||||
shrd eax,edx,16
|
||||
sar edx,16
|
||||
idiv ebx
|
||||
mov retour,eax
|
||||
}
|
||||
return retour;
|
||||
}
|
949
Rayman_X/cpa/tempgrp/TDE/tde_draw.c
Normal file
949
Rayman_X/cpa/tempgrp/TDE/tde_draw.c
Normal file
@@ -0,0 +1,949 @@
|
||||
/**************************************************************************************
|
||||
|
||||
DRAW.CPP
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
#include "tde.h"
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
a_lTableMM : Min-max array
|
||||
contains :
|
||||
| X_l | X_r | X_t_l | Y_t_l | X_t_r | Y_t_r | blank | blank |
|
||||
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
TDE_tdl1616 a_lTableMM[768][8];
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
Semi-transparency masks for 16 bits
|
||||
Force to 0 each component's last bit
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
unsigned short sMask_565 = 0xF7DE; // 1111 0111 1101 1110
|
||||
unsigned short sMask_655 = 0xFBDE; // 1111 1011 1101 1110
|
||||
unsigned short sMask_556 = 0xF7BE; // 1111 0111 1011 1110
|
||||
unsigned short sMask_555 = 0x7BDE; // 0111 1011 1101 1110
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawSuperObject16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a super object (for sprites)
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vDrawSuperObject16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterX, xSpriteCenterY,
|
||||
xSpriteCornerX, xSpriteCornerY, xScaledSourceW, xScaledSourceH,
|
||||
xSourceCornerX, xSourceCornerY;
|
||||
long lPitchDest, lPitchSrc, lViewPortW, lViewPortH;
|
||||
short si;
|
||||
TDE_tdsRect stSrcRect, stDestRect;
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
|
||||
stSrcRect.lPitch = lPitchSrc = ((long)(p_stSprite->stPicture.xSrcPitch))>>C_TDEDEC;
|
||||
stDestRect.lPitch = lPitchDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xScaledSpriteW = TDE_M_Mul(lViewPortW , p_stSprite->stDim.xX);
|
||||
xScaledSpriteH = TDE_M_Mul(lViewPortH , p_stSprite->stDim.xY);
|
||||
xSpriteCenterX = TDE_M_Mul(lViewPortW , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX);
|
||||
xSpriteCenterY = TDE_M_Mul(lViewPortH , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY);
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW,2);
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH,2);
|
||||
xSourceCornerX = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stSourceOrigin.xX);
|
||||
xSourceCornerY = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stSourceOrigin.xY);
|
||||
xScaledSourceW = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stDim.xX);
|
||||
xScaledSourceH = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stDim.xY);
|
||||
|
||||
// Destination rectangle
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX - xSpriteCenterX, xSpriteCornerY - xSpriteCenterY,
|
||||
xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
// Transformation
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xS), &(stDestRect.tdsSommet[si]), &(stDestRect.tdsSommet[si]));
|
||||
stDestRect.tdsSommet[si].xX += xSpriteCenterX;
|
||||
stDestRect.tdsSommet[si].xY += xSpriteCenterY;
|
||||
}
|
||||
|
||||
// Source rectangle
|
||||
iTDE_vFillsRect(&stSrcRect, xSourceCornerX, xSourceCornerY, xScaledSourceW, xScaledSourceH);
|
||||
|
||||
stDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
stSrcRect.p_usPointer = (TDE_tdxPixel *)(p_stSprite->stPicture.lp_Data);
|
||||
|
||||
if (!p_stSprite->cSemiTransparent)
|
||||
{ iTDE_vBlit(&stSrcRect, &stDestRect); }
|
||||
else
|
||||
{ iTDE_vBlit_Transparency(&stSrcRect, &stDestRect, p_stSprite->alpha); }
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawSuperObjectFast16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a super object (for sprites) without stretch
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vDrawSuperObjectFast16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterX, xSpriteCenterY,
|
||||
xSpriteCornerX, xSpriteCornerY, xScaledSourceW, xScaledSourceH,
|
||||
xSourceCornerX, xSourceCornerY;
|
||||
long lPitchDest, lPitchSrc, lViewPortW, lViewPortH;
|
||||
short si;
|
||||
TDE_tdsRect stSrcRect, stDestRect;
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
|
||||
stSrcRect.lPitch = lPitchSrc = ((long)(p_stSprite->stPicture.xSrcPitch))>>C_TDEDEC;
|
||||
stDestRect.lPitch = lPitchDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xSourceCornerX = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stSourceOrigin.xX);
|
||||
xSourceCornerY = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stSourceOrigin.xY);
|
||||
xScaledSourceW = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stDim.xX);
|
||||
xScaledSourceH = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stDim.xY);
|
||||
xScaledSpriteW = xScaledSourceW;
|
||||
xScaledSpriteH = xScaledSourceH;
|
||||
xSpriteCenterX = TDE_M_Mul(lViewPortW , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX);
|
||||
xSpriteCenterY = TDE_M_Mul(lViewPortH , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY);
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW,2);
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH,2);
|
||||
|
||||
// Destination rectangle
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX - xSpriteCenterX, xSpriteCornerY - xSpriteCenterY,
|
||||
xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
stDestRect.tdsSommet[si].xX += xSpriteCenterX;
|
||||
stDestRect.tdsSommet[si].xY += xSpriteCenterY;
|
||||
}
|
||||
|
||||
// Source rectangle
|
||||
iTDE_vFillsRect(&stSrcRect, xSourceCornerX, xSourceCornerY, xScaledSourceW, xScaledSourceH);
|
||||
|
||||
stDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
stSrcRect.p_usPointer = (TDE_tdxPixel *)(p_stSprite->stPicture.lp_Data);
|
||||
|
||||
iTDE_vBlitFast(&stSrcRect, &stDestRect);
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vFastDrawMemorySpriteAbsolute
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a sprite stored in memory
|
||||
! ATTENTION ! : The sprite has to be defined with absolute coordinates
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vFastDrawMemorySpriteAbsolute(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdsRect *p_stScreenRect)
|
||||
{
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterX, xSpriteCenterY,
|
||||
xSpriteCornerX, xSpriteCornerY;
|
||||
long lPitchDest, lViewPortW, lViewPortH;
|
||||
TDE_tdsRect stDestRect, stClippedDestRect;
|
||||
TDE_tdsMemZone stSource;
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
// clipping value 0->no clipped, 1->clipped to screen rect, 2->clipped to SO clipping rectangle
|
||||
char clipped = 0;
|
||||
|
||||
stDestRect.lPitch = lPitchDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xScaledSpriteW = p_stSprite->stDim.xX; // absolute dimensions
|
||||
xScaledSpriteH = p_stSprite->stDim.xY;
|
||||
xSpriteCenterX = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX;
|
||||
xSpriteCenterY = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY;
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW, 2) + 0.5;
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH, 2) + 0.5;
|
||||
|
||||
// Destination rectangle
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX, xSpriteCornerY, xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
// Out of screen ?
|
||||
if ( (long)(stDestRect.tdsSommet[0].xX)>p_stScreenRect->tdsSommet[1].xX) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xX)<p_stScreenRect->tdsSommet[0].xX) return;
|
||||
if ( (long)(stDestRect.tdsSommet[0].xY)>p_stScreenRect->tdsSommet[3].xY) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xY)<p_stScreenRect->tdsSommet[0].xY) return;
|
||||
|
||||
// Clipped ?
|
||||
if ( ( (long)(stDestRect.tdsSommet[0].xX)<p_stScreenRect->tdsSommet[0].xX) ||
|
||||
( (long)(stDestRect.tdsSommet[1].xX)>p_stScreenRect->tdsSommet[1].xX) ||
|
||||
( (long)(stDestRect.tdsSommet[0].xY)<p_stScreenRect->tdsSommet[0].xY) ||
|
||||
( (long)(stDestRect.tdsSommet[3].xY)>p_stScreenRect->tdsSommet[3].xY) )
|
||||
{
|
||||
clipped = 1;
|
||||
}
|
||||
|
||||
if (p_stSuperObject->p_stSOClipRect)
|
||||
clipped = 2;
|
||||
|
||||
if (clipped)
|
||||
{
|
||||
//iTDE_vAdjustScreenRectForClip(&stDestRect, &stClippedDestRect, lViewPortW, lViewPortH);
|
||||
if ( clipped == 1)
|
||||
iTDE_vAdjustScreenRectToClipRect(&stDestRect, &stClippedDestRect, p_stScreenRect);
|
||||
else if ( clipped == 2)
|
||||
iTDE_vAdjustScreenRectToClipRect(&stDestRect, &stClippedDestRect, p_stSuperObject->p_stSOClipRect);
|
||||
|
||||
stClippedDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
|
||||
stSource.p_usPointer = p_stSprite->v_pData + // recal
|
||||
TDE_M_ValueToLong (
|
||||
( TDE_M_ValueToLong(stClippedDestRect.tdsSommet[0].xY) - TDE_M_ValueToLong(stDestRect.tdsSommet[0].xY) )*xScaledSpriteW ) +
|
||||
( TDE_M_ValueToLong(stClippedDestRect.tdsSommet[0].xX) - TDE_M_ValueToLong(stDestRect.tdsSommet[0].xX) );
|
||||
|
||||
stSource.stDim.xX = xScaledSpriteW;
|
||||
stSource.stDim.xY = xScaledSpriteH;
|
||||
stSource.xMagicColor = p_stSprite->xMagicColor;
|
||||
|
||||
if (p_stSprite->c_NZ)
|
||||
{ iTDE_vBlitClipMemory_NZ(&stSource, &stClippedDestRect); }
|
||||
else
|
||||
{ iTDE_vBlitClipMemory(&stSource, &stClippedDestRect); }
|
||||
}
|
||||
else
|
||||
{
|
||||
stDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
stSource.p_usPointer = (TDE_tdxPixel *)(p_stSprite->v_pData);
|
||||
stSource.stDim.xX = xScaledSpriteW;
|
||||
stSource.stDim.xY = xScaledSpriteH;
|
||||
stSource.xMagicColor = p_stSprite->xMagicColor;
|
||||
|
||||
if (p_stSprite->c_NZ)
|
||||
{ iTDE_vBlitFastMemory_NZ(&stSource, &stDestRect); }
|
||||
else
|
||||
{ iTDE_vBlitFastMemory(&stSource, &stDestRect); }
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vFastDrawMemorySpriteAbsoluteInvert
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a sprite stored in memory
|
||||
! ATTENTION ! : The sprite has to be defined with absolute coordinates
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vFastDrawMemorySpriteAbsoluteInvert(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdsRect *p_stScreenRect)
|
||||
{
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterX, xSpriteCenterY,
|
||||
xSpriteCornerX, xSpriteCornerY;
|
||||
long lPitchDest, lViewPortW, lViewPortH;
|
||||
TDE_tdsRect stDestRect, stClippedDestRect;
|
||||
TDE_tdsMemZone stSource;
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
char clipped = 0;
|
||||
|
||||
stDestRect.lPitch = lPitchDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xScaledSpriteW = p_stSprite->stDim.xX; // absolute dimensions
|
||||
xScaledSpriteH = p_stSprite->stDim.xY;
|
||||
xSpriteCenterX = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX;
|
||||
xSpriteCenterY = p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY;
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW, 2) + 0.5;
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH, 2) + 0.5;
|
||||
|
||||
// Destination rectangle
|
||||
/*
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX - xSpriteCenterX, xSpriteCornerY - xSpriteCenterY,
|
||||
xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
stDestRect.tdsSommet[si].xX += xSpriteCenterX;
|
||||
stDestRect.tdsSommet[si].xY += xSpriteCenterY;
|
||||
}
|
||||
*/
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX, xSpriteCornerY, xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
// Out of screen ?
|
||||
if ( (long)(stDestRect.tdsSommet[0].xX)>p_stScreenRect->tdsSommet[1].xX) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xX)<p_stScreenRect->tdsSommet[0].xX) return;
|
||||
if ( (long)(stDestRect.tdsSommet[0].xY)>p_stScreenRect->tdsSommet[3].xY) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xY)<p_stScreenRect->tdsSommet[0].xY) return;
|
||||
|
||||
// Clipped ?
|
||||
if ( ( (long)(stDestRect.tdsSommet[0].xX)<p_stScreenRect->tdsSommet[0].xX) ||
|
||||
( (long)(stDestRect.tdsSommet[1].xX)>p_stScreenRect->tdsSommet[1].xX) ||
|
||||
( (long)(stDestRect.tdsSommet[0].xY)<p_stScreenRect->tdsSommet[0].xY) ||
|
||||
( (long)(stDestRect.tdsSommet[3].xY)>p_stScreenRect->tdsSommet[3].xY) )
|
||||
{
|
||||
clipped = 1;
|
||||
}
|
||||
|
||||
if (p_stSuperObject->p_stSOClipRect)
|
||||
clipped = 2;
|
||||
|
||||
if ( clipped == 1 )
|
||||
{
|
||||
//iTDE_vAdjustScreenRectForClip(&stDestRect, &stClippedDestRect, lViewPortW, lViewPortH);
|
||||
if ( clipped == 1)
|
||||
iTDE_vAdjustScreenRectToClipRect(&stDestRect, &stClippedDestRect, p_stScreenRect);
|
||||
else if ( clipped == 2)
|
||||
iTDE_vAdjustScreenRectToClipRect(&stDestRect, &stClippedDestRect, p_stSuperObject->p_stSOClipRect);
|
||||
|
||||
stClippedDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
|
||||
stSource.p_usPointer = p_stSprite->v_pData + // recal
|
||||
TDE_M_ValueToLong (
|
||||
( TDE_M_ValueToLong(stClippedDestRect.tdsSommet[0].xY) - TDE_M_ValueToLong(stDestRect.tdsSommet[0].xY) )*xScaledSpriteW ) +
|
||||
( TDE_M_ValueToLong(stClippedDestRect.tdsSommet[0].xX) - TDE_M_ValueToLong(stDestRect.tdsSommet[0].xX) );
|
||||
|
||||
stSource.stDim.xX = xScaledSpriteW;
|
||||
stSource.stDim.xY = xScaledSpriteH;
|
||||
stSource.xMagicColor = p_stSprite->xMagicColor;
|
||||
|
||||
if (p_stSprite->c_NZ)
|
||||
{ iTDE_vBlitClipMemory_Invert_NZ(&stSource, &stClippedDestRect); }
|
||||
else
|
||||
{ iTDE_vBlitClipMemory_Invert(&stSource, &stClippedDestRect); }
|
||||
}
|
||||
else
|
||||
{
|
||||
stDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
stSource.p_usPointer = (TDE_tdxPixel *)(p_stSprite->v_pData);
|
||||
stSource.stDim.xX = xScaledSpriteW;
|
||||
stSource.stDim.xY = xScaledSpriteH;
|
||||
stSource.xMagicColor = p_stSprite->xMagicColor;
|
||||
|
||||
if (p_stSprite->c_NZ)
|
||||
{ iTDE_vBlitFastMemory_Invert_NZ(&stSource, &stDestRect); }
|
||||
else
|
||||
{ iTDE_vBlitFastMemory_Invert(&stSource, &stDestRect); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TDE_vFastDrawBackGround(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
TDE_tdxPixel *src, *dest;
|
||||
|
||||
dest = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
src = p_stSprite->v_pData;
|
||||
|
||||
//iTDE_vBackground((long *)src, (long *)dest);
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawSuperObjectClipped16
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a super object with clipping (for sprites)
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vDrawSuperObjectClipped16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterX, xSpriteCenterY,
|
||||
xSpriteCornerX, xSpriteCornerY, xSourceCornerX, xSourceCornerY,
|
||||
xScaledSourceW, xScaledSourceH;
|
||||
long lPitchDest, lPitchSrc, lViewPortW, lViewPortH;
|
||||
short si;
|
||||
TDE_tdsRect stSrcRect, stDestRect, stClippedDestRect,
|
||||
stSrcFlippedRect, stSrcClippedRect;
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
|
||||
stSrcRect.lPitch = lPitchSrc = ((long)(p_stSprite->stPicture.xSrcPitch))>>C_TDEDEC;
|
||||
stDestRect.lPitch = lPitchDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xScaledSpriteW = TDE_M_Mul(lViewPortW , p_stSprite->stDim.xX);
|
||||
xScaledSpriteH = TDE_M_Mul(lViewPortH , p_stSprite->stDim.xY);
|
||||
xSpriteCenterX = TDE_M_Mul(lViewPortW , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX);
|
||||
xSpriteCenterY = TDE_M_Mul(lViewPortH , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY);
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW,2);
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH,2);
|
||||
xSourceCornerX = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stSourceOrigin.xX);
|
||||
xSourceCornerY = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stSourceOrigin.xY);
|
||||
xScaledSourceW = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stDim.xX);
|
||||
xScaledSourceH = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stDim.xY);
|
||||
|
||||
// Screen rectangle
|
||||
iTDE_vFillsRect(&stDestRect, xSpriteCornerX - xSpriteCenterX, xSpriteCornerY - xSpriteCenterY,
|
||||
xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
// Transformation
|
||||
for ( si=0; si<4; si++ )
|
||||
{
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xS), &(stDestRect.tdsSommet[si]), &(stDestRect.tdsSommet[si]));
|
||||
stDestRect.tdsSommet[si].xX += xSpriteCenterX;
|
||||
stDestRect.tdsSommet[si].xY += xSpriteCenterY;
|
||||
}
|
||||
|
||||
// Out of screen
|
||||
if ( (long)(stDestRect.tdsSommet[0].xX)>lViewPortW ) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xX)<0 ) return;
|
||||
if ( (long)(stDestRect.tdsSommet[0].xY)>lViewPortH ) return;
|
||||
if ( (long)(stDestRect.tdsSommet[2].xY)<0 ) return;
|
||||
|
||||
// Adjust destination rectangle for clipping
|
||||
iTDE_vAdjustScreenRectForClip(&stDestRect, &stClippedDestRect, lViewPortW, lViewPortH);
|
||||
|
||||
stClippedDestRect.p_usPointer = (TDE_tdxPixel *)(p_stViewAttrib->p_cVirtualScreen);
|
||||
|
||||
// Source rectangle
|
||||
iTDE_vFillsRect(&stSrcRect, xSourceCornerX, xSourceCornerY, xScaledSourceW, xScaledSourceH);
|
||||
stSrcRect.p_usPointer = (TDE_tdxPixel *)(p_stSprite->stPicture.lp_Data);
|
||||
|
||||
// Adjust source rectangle for flip
|
||||
iTDE_vAdjustRectToFlip(&stSrcRect, &stSrcFlippedRect, p_stSprite->cFlip);
|
||||
|
||||
// Adjust source rectangle for clip
|
||||
iTDE_vAdjustSourceRectForClip(&stDestRect, &stSrcFlippedRect, &stSrcClippedRect, lViewPortW, lViewPortH);
|
||||
|
||||
// Drawing loop
|
||||
if ( !p_stSprite->cSemiTransparent )
|
||||
{ iTDE_vBlit(&stSrcClippedRect, &stClippedDestRect); }
|
||||
else
|
||||
{ iTDE_vBlit_Transparency(&stSrcClippedRect, &stClippedDestRect, p_stSprite->alpha); }
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vCalculateIntermediateVertex
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Calculate the clipped vertex between two points
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vCalculateIntermediateVertex(TDE_tdsClippedVertex1616 *Result_Point, TDE_tdsClippedVertex1616 *Point1, TDE_tdsClippedVertex1616 *Point2, TDE_tdl1616 lValue1, TDE_tdl1616 lValue2, TDE_tdl1616 lInterValue)
|
||||
{
|
||||
TDE_tdl1616 lInvert;
|
||||
|
||||
lInvert = TDE_DIV ( (lInterValue-lValue2) , (lValue1-lValue2) );
|
||||
Result_Point->Point.lX = Point2->Point.lX + TDE_MUL( (Point1->Point.lX) - (Point2->Point.lX), lInvert ) ;
|
||||
Result_Point->Point.lY = Point2->Point.lY + TDE_MUL( (Point1->Point.lY) - (Point2->Point.lY), lInvert ) ;
|
||||
Result_Point->TexPoint.lX = Point2->TexPoint.lX + TDE_MUL( Point1->TexPoint.lX - Point2->TexPoint.lX, lInvert );
|
||||
Result_Point->TexPoint.lY = Point2->TexPoint.lY + TDE_MUL( Point1->TexPoint.lY - Point2->TexPoint.lY, lInvert );
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_lClipPolygon
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Clip a polygon
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
long TDE_cClipPolygon(char cNB_SOMMETS, TDE_tdsClippedVertex1616 *p_stClipped_Line, long lWidth, long lHeight)
|
||||
{
|
||||
char cNB_SOMMETS2, cIndix, cVertexIndix, cClipped_NB_Sommets, cOver;
|
||||
TDE_tdl1616 lYemin1616, lYemax1616, lXemin1616, lXemax1616;
|
||||
TDE_tdsClippedVertex1616 *p_stCLineInter1, *p_stCLineInter2, *p_stCLine2Inter, p_stClipped_Line_2[20];
|
||||
|
||||
lYemin1616 = 1<<16;
|
||||
lYemax1616 = (lHeight-1)<<16;
|
||||
lXemin1616 = 1<<16;
|
||||
lXemax1616 = (lWidth-1)<<16;
|
||||
|
||||
// Top cutting
|
||||
cVertexIndix = (char)(cNB_SOMMETS-1);
|
||||
cClipped_NB_Sommets = 0;
|
||||
|
||||
p_stCLineInter2 = &p_stClipped_Line[cVertexIndix];
|
||||
p_stCLineInter1 = &p_stClipped_Line[0];
|
||||
p_stCLine2Inter = &p_stClipped_Line_2[0];
|
||||
for (cIndix=0; cIndix<cNB_SOMMETS; cIndix++)
|
||||
{
|
||||
cOver = 0;
|
||||
if (p_stCLineInter1->Point.lY>=lYemin1616) cOver = 1;
|
||||
if (p_stCLineInter2->Point.lY>=lYemin1616) cOver |= 2;
|
||||
switch (cOver&3) {
|
||||
case 3:
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
case 1:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter1, p_stCLineInter2, p_stCLineInter1->Point.lY, p_stCLineInter2->Point.lY, lYemin1616);
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets += 2;
|
||||
break;
|
||||
case 2:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter2, p_stCLineInter1, p_stCLineInter2->Point.lY, p_stCLineInter1->Point.lY, lYemin1616);
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
}
|
||||
p_stCLineInter2 = p_stCLineInter1;
|
||||
p_stCLineInter1++;
|
||||
}
|
||||
if (cClipped_NB_Sommets<2) return(0);
|
||||
cNB_SOMMETS2 = cClipped_NB_Sommets;
|
||||
|
||||
// Bottom cutting
|
||||
cVertexIndix = (char)(cNB_SOMMETS2-1);
|
||||
cClipped_NB_Sommets = 0;
|
||||
p_stCLineInter2 = &p_stClipped_Line_2[cVertexIndix];
|
||||
p_stCLineInter1 = &p_stClipped_Line_2[0];
|
||||
p_stCLine2Inter = &p_stClipped_Line[0];
|
||||
for (cIndix=0; cIndix<cNB_SOMMETS2; cIndix++)
|
||||
{
|
||||
cOver = 0;
|
||||
if (p_stCLineInter1->Point.lY<=lYemax1616) cOver = 1;
|
||||
if (p_stCLineInter2->Point.lY<=lYemax1616) cOver |= 2;
|
||||
switch (cOver&3) {
|
||||
case 3:
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter1, p_stCLineInter2, p_stCLineInter1->Point.lY, p_stCLineInter2->Point.lY, lYemax1616);
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets += 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter2, p_stCLineInter1, p_stCLineInter2->Point.lY, p_stCLineInter1->Point.lY, lYemax1616);
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
}
|
||||
p_stCLineInter2 = p_stCLineInter1;
|
||||
p_stCLineInter1++;
|
||||
}
|
||||
if (cClipped_NB_Sommets<2) return(0);
|
||||
cNB_SOMMETS = cClipped_NB_Sommets;
|
||||
|
||||
// Left cutting
|
||||
|
||||
cVertexIndix= (char)(cNB_SOMMETS-1);
|
||||
cClipped_NB_Sommets = 0;
|
||||
p_stCLineInter2 = &p_stClipped_Line[cVertexIndix];
|
||||
p_stCLineInter1 = &p_stClipped_Line[0];
|
||||
p_stCLine2Inter = &p_stClipped_Line_2[0];
|
||||
for (cIndix=0; cIndix<cNB_SOMMETS; cIndix++)
|
||||
{
|
||||
cOver = 0;
|
||||
if (p_stCLineInter1->Point.lX>=lXemin1616) cOver = 1;
|
||||
if (p_stCLineInter2->Point.lX>=lXemin1616) cOver |= 2;
|
||||
switch (cOver&3) {
|
||||
case 3:
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
case 1:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter1, p_stCLineInter2, p_stCLineInter1->Point.lX, p_stCLineInter2->Point.lX, lXemin1616);
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets += 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter2, p_stCLineInter1, p_stCLineInter2->Point.lX, p_stCLineInter1->Point.lX, lXemin1616);
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
}
|
||||
p_stCLineInter2 = p_stCLineInter1;
|
||||
p_stCLineInter1++;
|
||||
}
|
||||
if (cClipped_NB_Sommets<2) return(0);
|
||||
|
||||
// Right cutting
|
||||
|
||||
cNB_SOMMETS2 = cClipped_NB_Sommets;
|
||||
cVertexIndix = (char)(cNB_SOMMETS2-1);
|
||||
cClipped_NB_Sommets = 0;
|
||||
p_stCLineInter2 = &p_stClipped_Line_2[cVertexIndix];
|
||||
p_stCLineInter1 = &p_stClipped_Line_2[0];
|
||||
p_stCLine2Inter = p_stClipped_Line;
|
||||
for (cIndix=0; cIndix<cNB_SOMMETS2; cIndix++)
|
||||
{
|
||||
cOver = 0;
|
||||
if (p_stCLineInter1->Point.lX<=lXemax1616) cOver = 1;
|
||||
if (p_stCLineInter2->Point.lX<=lXemax1616) cOver |= 2;
|
||||
switch (cOver&3) {
|
||||
case 3:
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
case 1:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter1, p_stCLineInter2, p_stCLineInter1->Point.lX, p_stCLineInter2->Point.lX, lXemax1616);
|
||||
*(p_stCLine2Inter++) = *p_stCLineInter1;
|
||||
cClipped_NB_Sommets += 2;
|
||||
break;
|
||||
case 2:
|
||||
TDE_vCalculateIntermediateVertex(p_stCLine2Inter++, p_stCLineInter2, p_stCLineInter1, p_stCLineInter2->Point.lX, p_stCLineInter1->Point.lX, lXemax1616);
|
||||
cClipped_NB_Sommets++;
|
||||
break;
|
||||
}
|
||||
p_stCLineInter2 = p_stCLineInter1;
|
||||
p_stCLineInter1++;
|
||||
}
|
||||
|
||||
if (cClipped_NB_Sommets<2) return(0);
|
||||
return(cClipped_NB_Sommets);
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vFillTableMM
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fill the Min-Max Table
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vFillTableMM(long lStart, long lLenght, long lColumn, TDE_tdl1616 lValue1, TDE_tdl1616 lValue2)
|
||||
{
|
||||
TDE_tdl1616 *p_MMStart, *p_MMEnd;
|
||||
TDE_tdl1616 lVinc;
|
||||
|
||||
if (lValue2 != lValue1)
|
||||
{
|
||||
lVinc = TDE_DIV( lValue2-lValue1 , (lLenght<<16) );
|
||||
p_MMStart = &a_lTableMM[lStart][lColumn];
|
||||
p_MMEnd = p_MMStart + (lLenght<<3);
|
||||
for (;p_MMStart<p_MMEnd; p_MMStart=p_MMStart+8, lValue1 += lVinc)
|
||||
*p_MMStart = lValue1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_MMStart = &a_lTableMM[lStart][lColumn];
|
||||
p_MMEnd = p_MMStart+(lLenght<<3);
|
||||
for (;p_MMStart<p_MMEnd; p_MMStart = p_MMStart+8)
|
||||
*p_MMStart = lValue1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TDE_vDrawSuperObjectRotated16(GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdxValue xW, xH, xXc, xYc, xXs, xYs, xWs, xHs, xX, xY;
|
||||
TDE_tdl1616 lXg, lXd, lUg, lUd, lVg, lVd, ldU, ldV, ldX,
|
||||
ldE, lF, ldF, ldY;
|
||||
short si;
|
||||
long lPitSrc, lPitDest, lgW, lgH,
|
||||
lNBSommets, lYmin, lYmax, *T_H, lMiddle;
|
||||
TDE_tdxPixel *p_usDest, *p_usDestEnd, *p_usDestSave, *p_usOfs, *p_usL,
|
||||
c, usSpritePixel, usBackPixel;
|
||||
TDE_tdsClippedVertex1616 Polygon[8], *Ptr1, *Ptr2;
|
||||
TDE_tdsClippedVertex xPolygon[8];
|
||||
|
||||
TDE_tdsSprite *p_stSprite = p_stSuperObject->p_stSprite;
|
||||
|
||||
// Variables for alpha-transparency
|
||||
short sBlueMask = 0x001F; // 0000 0000 0001 1111 -> obtain blue component
|
||||
short sGreenMask = 0x07E0; // 0000 0111 1110 0000 -> obtain green component
|
||||
// short sRedMask = 0xF800; // 1111 1000 0000 0000 -> obtain red component
|
||||
short sB, sG, sR;
|
||||
char cIndix1, cIndix2;
|
||||
unsigned char *p_cAcc15, *p_cAcc25, *p_cAcc16, *p_cAcc26;
|
||||
|
||||
lPitSrc = ((long)(p_stSprite->stPicture.xSrcPitch))>>C_TDEDEC;
|
||||
lPitDest = (p_stViewAttrib->lPitch)>>C_TDEDEC;
|
||||
lgW = p_stViewAttrib->dwWidth;
|
||||
lgH = p_stViewAttrib->dwHeight;
|
||||
|
||||
// xValues
|
||||
xW = TDE_M_Mul(lgW , p_stSprite->stDim.xX);
|
||||
xH = TDE_M_Mul(lgH , p_stSprite->stDim.xY);
|
||||
xXc = TDE_M_Mul(lgW , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xX);
|
||||
xYc = TDE_M_Mul(lgH , p_stSuperObject->stModifiedMatrix.stTranslateVertex.xY);
|
||||
xXs = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stSourceOrigin.xX);
|
||||
xYs = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stSourceOrigin.xY);
|
||||
xWs = TDE_M_Mul(p_stSprite->stPicture.xWidth , p_stSprite->stDim.xX);
|
||||
xHs = TDE_M_Mul(p_stSprite->stPicture.xHeight , p_stSprite->stDim.xY);
|
||||
xX = xXc - TDE_M_Div(xW,2);
|
||||
xY = xYc - TDE_M_Div(xH,2);
|
||||
|
||||
p_usOfs = p_usL = (TDE_tdxPixel *)(p_stSprite->stPicture.lp_Data);
|
||||
p_usDest = (TDE_tdxPixel *)p_stViewAttrib->p_cVirtualScreen;
|
||||
|
||||
if (((xX+xW)<=1.0)||(xX>=lgW)) return;
|
||||
if (((xY+xH)<=1.0)||(xY>=lgH)) return;
|
||||
|
||||
xPolygon[0].Point.xX = xX-xXc;
|
||||
xPolygon[0].Point.xY = xY-xYc;
|
||||
|
||||
xPolygon[1].Point.xX = xX+xW-xXc;
|
||||
xPolygon[1].Point.xY = xY-xYc;
|
||||
|
||||
xPolygon[2].Point.xX = xX+xW-xXc;
|
||||
xPolygon[2].Point.xY = xY+xH-xYc;
|
||||
|
||||
xPolygon[3].Point.xX = xX-xXc;
|
||||
xPolygon[3].Point.xY = xY+xH-xYc;
|
||||
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
TDE_vMulMatrixByVertex(&(p_stSuperObject->stModifiedMatrix.a4_xRxS), &xPolygon[si].Point, &xPolygon[si].Point);
|
||||
xPolygon[si].Point.xX += xXc;
|
||||
xPolygon[si].Point.xY += xYc;
|
||||
}
|
||||
|
||||
xPolygon[0].TexPoint.xX = xPolygon[3].TexPoint.xX = xXs;
|
||||
xPolygon[1].TexPoint.xX = xPolygon[2].TexPoint.xX = xXs+xWs;
|
||||
|
||||
xPolygon[0].TexPoint.xY = xPolygon[1].TexPoint.xY = xYs;
|
||||
xPolygon[2].TexPoint.xY = xPolygon[3].TexPoint.xY = xYs+xHs;
|
||||
|
||||
// xPolygon -> Polygon
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
Polygon[si].Point.lX = TDE_M_ValueTo1616(xPolygon[si].Point.xX);
|
||||
Polygon[si].Point.lY = TDE_M_ValueTo1616(xPolygon[si].Point.xY);
|
||||
Polygon[si].TexPoint.lX = TDE_M_ValueTo1616(xPolygon[si].TexPoint.xX);
|
||||
Polygon[si].TexPoint.lY = TDE_M_ValueTo1616(xPolygon[si].TexPoint.xY);
|
||||
}
|
||||
|
||||
// Clip
|
||||
lNBSommets = TDE_cClipPolygon(4, Polygon, lgW, lgH);
|
||||
|
||||
// 16:16 -> int
|
||||
for (si=0; si<lNBSommets; si++)
|
||||
Polygon[si].Point.lY>>=16;
|
||||
|
||||
// Fills min-max table
|
||||
if (lNBSommets>2)
|
||||
{
|
||||
Ptr1 = &Polygon[0];
|
||||
Ptr2 = &Polygon[lNBSommets-1];
|
||||
lYmin = Ptr2->Point.lY;
|
||||
lYmax = Ptr2->Point.lY;
|
||||
for (si=0; si<lNBSommets; si++)
|
||||
{
|
||||
if (Ptr1->Point.lY<lYmin) lYmin = Ptr1->Point.lY;
|
||||
if (Ptr1->Point.lY>lYmax) lYmax = Ptr1->Point.lY;
|
||||
if (Ptr2->Point.lY<Ptr1->Point.lY)
|
||||
{ // Right
|
||||
TDE_vFillTableMM(Ptr2->Point.lY, Ptr1->Point.lY-Ptr2->Point.lY, 1, Ptr2->Point.lX, Ptr1->Point.lX);
|
||||
TDE_vFillTableMM(Ptr2->Point.lY, Ptr1->Point.lY-Ptr2->Point.lY, 4, Ptr2->TexPoint.lX, Ptr1->TexPoint.lX);
|
||||
TDE_vFillTableMM(Ptr2->Point.lY, Ptr1->Point.lY-Ptr2->Point.lY, 5, Ptr2->TexPoint.lY, Ptr1->TexPoint.lY);
|
||||
}
|
||||
else if (Ptr2->Point.lY>Ptr1->Point.lY)
|
||||
{ // Left
|
||||
TDE_vFillTableMM(Ptr1->Point.lY, Ptr2->Point.lY-Ptr1->Point.lY, 0, (Ptr1->Point.lX), (Ptr2->Point.lX));
|
||||
TDE_vFillTableMM(Ptr1->Point.lY, Ptr2->Point.lY-Ptr1->Point.lY, 2, (Ptr1->TexPoint.lX), (Ptr2->TexPoint.lX));
|
||||
TDE_vFillTableMM(Ptr1->Point.lY, Ptr2->Point.lY-Ptr1->Point.lY, 3, (Ptr1->TexPoint.lY), (Ptr2->TexPoint.lY));
|
||||
}
|
||||
Ptr2=Ptr1;
|
||||
Ptr1++;
|
||||
}
|
||||
}
|
||||
|
||||
// Is the sprite out of screen (Y) ?
|
||||
if ((lYmin>=(lgH-1))||(lYmax<=1)) return;
|
||||
|
||||
// Increments calculation
|
||||
lMiddle = lYmin+((lYmax-lYmin)>>1);
|
||||
if ((lMiddle<0)||(lMiddle>768)) return; // debug
|
||||
T_H = &a_lTableMM[lMiddle][0];
|
||||
ldX = *(T_H+1) - *(T_H);
|
||||
lUg = *(T_H+2);
|
||||
lVg = *(T_H+3);
|
||||
lUd = *(T_H+4);
|
||||
lVd = *(T_H+5);
|
||||
|
||||
if (ldX>0)
|
||||
{
|
||||
ldU = TDE_DIV((lUd-lUg),ldX);
|
||||
ldV = TDE_DIV((lVd-lVg),ldX);
|
||||
}
|
||||
else return;
|
||||
|
||||
ldE = lPitSrc*(ldV>>16)+(ldU>>16);
|
||||
ldF = ((ldV>>1)&0x7FFF)+((ldU<<15)&0x7FFF0000);
|
||||
T_H = &a_lTableMM[lYmin][0];
|
||||
p_usDest += lYmin*lPitDest;
|
||||
ldY = lYmax-lYmin;
|
||||
|
||||
// Main loop
|
||||
|
||||
if (!p_stSprite->cSemiTransparent)
|
||||
{
|
||||
// No semi-transparency
|
||||
for (si=0; si<ldY; si++,T_H+=8)
|
||||
{
|
||||
lXg = *(T_H)>>16;
|
||||
lXd = *(T_H+1)>>16;
|
||||
lUg = *(T_H+2);
|
||||
lVg = *(T_H+3);
|
||||
lF = ((lVg>>1)&0x7FFF)+((lUg<<15)&0x7FFF0000);
|
||||
p_usOfs = p_usL + lPitSrc*(lVg>>16)+(lUg>>16);
|
||||
p_usDestSave = p_usDest;
|
||||
p_usDestEnd = p_usDest+lXd;
|
||||
|
||||
for (p_usDest=p_usDest+lXg; p_usDest<p_usDestEnd; p_usDest++)
|
||||
{
|
||||
//if (p_cOfs>p_cL) // debug
|
||||
c = *p_usOfs;
|
||||
if (c>0)
|
||||
*p_usDest = c;
|
||||
lF += ldF;
|
||||
p_usOfs += ldE;
|
||||
if (lF&0x8000) {lF&=0xFFFF7FFF; p_usOfs+=lPitSrc; }
|
||||
if (lF&0x80000000) {lF&=0x7FFFFFFF; p_usOfs++; }
|
||||
}
|
||||
|
||||
p_usDest = p_usDestSave + lPitDest;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
cIndix1 = ((char)(p_stSprite->alpha*64))&0x3F;
|
||||
cIndix2 = 63-cIndix1;
|
||||
p_cAcc15 = &(a_cTransparencyTable5[cIndix1][0]);
|
||||
p_cAcc25 = &(a_cTransparencyTable5[cIndix2][0]);
|
||||
p_cAcc16 = &(a_cTransparencyTable6[cIndix1][0]);
|
||||
p_cAcc26 = &(a_cTransparencyTable6[cIndix2][0]);
|
||||
|
||||
// semi-transparency
|
||||
for (si=0; si<ldY; si++,T_H+=8)
|
||||
{
|
||||
lXg = *(T_H)>>16;
|
||||
lXd = *(T_H+1)>>16;
|
||||
lUg = *(T_H+2);
|
||||
lVg = *(T_H+3);
|
||||
lF = ((lVg>>1)&0x7FFF)+((lUg<<15)&0x7FFF0000);
|
||||
p_usOfs = p_usL + lPitSrc*(lVg>>16)+(lUg>>16);
|
||||
p_usDestSave = p_usDest;
|
||||
p_usDestEnd = p_usDest + lXd;
|
||||
|
||||
|
||||
for (p_usDest=p_usDest+lXg; p_usDest<p_usDestEnd; p_usDest++)
|
||||
{
|
||||
usSpritePixel = *p_usOfs;
|
||||
if (usSpritePixel>0)
|
||||
{
|
||||
usBackPixel = *p_usDest;
|
||||
sB = *(p_cAcc15 + (usBackPixel & sBlueMask)) + *(p_cAcc25+ (usSpritePixel & sBlueMask));
|
||||
sG = *(p_cAcc16 + ((usBackPixel & sGreenMask)>>5)) + *(p_cAcc26 + ((usSpritePixel & sGreenMask)>>5));
|
||||
sR = *(p_cAcc15 + (usBackPixel>>11)) + *(p_cAcc25 + (usSpritePixel>>11));
|
||||
*p_usDest = sB+(sG<<5)+(sR<<11);
|
||||
}
|
||||
lF += ldF;
|
||||
p_usOfs += ldE;
|
||||
if (lF&0x8000) {lF&=0xFFFF7FFF; p_usOfs+=lPitSrc; }
|
||||
if (lF&0x80000000) {lF&=0x7FFFFFFF; p_usOfs++; }
|
||||
}
|
||||
p_usDest = p_usDestSave + lPitDest;
|
||||
|
||||
}
|
||||
} // if (!p_stSprite->cSemiTransparent ....)
|
||||
}
|
||||
|
||||
void TDE_vResetTable()
|
||||
{
|
||||
short si, sj;
|
||||
|
||||
for (si=0; si<768; si++)
|
||||
{
|
||||
for (sj=0; sj<8; sj++) a_lTableMM[si][sj] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TDE_vSendObjectsToViewPort(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObject, TDE_p_stSuperObject *ZList)
|
||||
{
|
||||
//TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
// Reset matrices stack (!)
|
||||
ResetMatrixStack((TDE_tdsCamera *)(p_stViewAttrib->p_vSpecificToXD));
|
||||
// Init Z list
|
||||
TDE_vInitZList(ZList);
|
||||
// Rebuild all SuperObjects matrices
|
||||
TDE_vCreateSuperObjectDescendancyMatrices(p_stSuperObject);
|
||||
// Build Z list
|
||||
TDE_vBuildHierarchy(p_stSuperObject, ZList);
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vSendListToViewPort
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Send Z liste to a viewport
|
||||
Disposable functions :
|
||||
TDE_vDrawSuperObject16(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObjet);
|
||||
TDE_vDrawSuperObjectFast16(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObjet);
|
||||
TDE_vDrawMemSprite_Abs_16(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObjet);
|
||||
TDE_vDrawSuperObjectRotated16(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObjet);
|
||||
TDE_vDrawSuperObjectClipped16(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_tdsSuperObject *p_stSuperObjet);
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vSendListToViewPort(GLD_tdpstViewportAttributes p_stViewAttrib, TDE_p_stSuperObject *ZList, TDE_tdsRect *stClipScreenRect, BOOL bViewPortLocked)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
short si;
|
||||
|
||||
// Draw ZList
|
||||
if (bViewPortLocked)
|
||||
{
|
||||
// Viewport is locked : draw everything but True Type text
|
||||
for (si=0; si<TDE_kMAXPRIORITY; si++)
|
||||
{
|
||||
if (ZList[si]!=NULL)
|
||||
for (p_stSuperObjectTemp = ZList[si]; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stNextZList)
|
||||
{
|
||||
if (p_stSuperObjectTemp->p_vPointer != NULL)
|
||||
{
|
||||
switch (p_stSuperObjectTemp->eType)
|
||||
{
|
||||
case TDE_eOT_SPRITE:
|
||||
TDE_vFastDrawMemorySpriteAbsolute(p_stViewAttrib, p_stSuperObjectTemp, stClipScreenRect);
|
||||
break;
|
||||
case TDE_eOT_TEXTBOX:
|
||||
TDE_vDrawTextInABox(p_stViewAttrib, p_stSuperObjectTemp, TRUE);
|
||||
break;
|
||||
case TDE_eOT_LINE:
|
||||
TDE_vDrawSuperObjectLineAbs(p_stViewAttrib, p_stSuperObjectTemp);
|
||||
break;
|
||||
case TDE_eOT_EMPTY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Viewport is not locked : draw nothing but True Type text
|
||||
for (si=0; si<TDE_kMAXPRIORITY; si++)
|
||||
{
|
||||
if (ZList[si]!=NULL)
|
||||
for (p_stSuperObjectTemp = ZList[si]; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stNextZList)
|
||||
{
|
||||
if (p_stSuperObjectTemp->p_vPointer != NULL)
|
||||
{
|
||||
switch (p_stSuperObjectTemp->eType)
|
||||
{
|
||||
case TDE_eOT_TEXTBOX:
|
||||
TDE_vDrawTextInABox(p_stViewAttrib, p_stSuperObjectTemp, FALSE);
|
||||
break;
|
||||
case TDE_eOT_EMPTY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
579
Rayman_X/cpa/tempgrp/TDE/tde_dtext.c
Normal file
579
Rayman_X/cpa/tempgrp/TDE/tde_dtext.c
Normal file
@@ -0,0 +1,579 @@
|
||||
/**************************************************************************************
|
||||
|
||||
TDE_DRAWTEXT.C
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
#include "tde.h"
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_bIsBreakChar
|
||||
VERSION : 1.0 / Yan
|
||||
|
||||
AIM : Tells if a character can be a breakpoint of the line, in DT_WORDBREAK mode
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
BOOL TDE_bIsBreakChar (char c)
|
||||
{
|
||||
// Any control character breaks the word
|
||||
if (c < 0x20)
|
||||
return TRUE;
|
||||
|
||||
// ' ' and '-' break the word. Other characters don't.
|
||||
switch (c)
|
||||
{
|
||||
case ' ':
|
||||
case '-':
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_xGetVerticalOffset
|
||||
VERSION : 1.0 / Yan
|
||||
|
||||
AIM : Get the first vertical offset and the maximal number of lines for a character string
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
TDE_tdxValue TDE_xGetVerticalOffset (TDE_tdsTextBox *pTextBox, long *p_lNbLines)
|
||||
{
|
||||
unsigned long ulStyle; // Format attributes
|
||||
TDE_tdxValue xTopRect; // Top of the format rectangle
|
||||
TDE_tdxValue xBottomRect; // Bottom of the format rectangle
|
||||
TDE_tdxValue xHMax; // Maximum high part in the font
|
||||
TDE_tdxValue xVAMax; // Maximum low part (vertical alignment) in the font
|
||||
TDE_tdsBitmapFont *pFont; // Pointer to the bitmap font
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_lNbLines == NULL) // NULL pointer to number of lines
|
||||
return 0;
|
||||
if (pTextBox == NULL) // NULL pointer to text box
|
||||
{ *p_lNbLines = 0; return 0; }
|
||||
if (pTextBox->eFontType != TDE_eFT_BITMAP) // Non-bitmap font
|
||||
{ *p_lNbLines = 0; return 0; }
|
||||
if (pTextBox->p_stBFont == NULL) // NULL pointer to bitmap font
|
||||
{ *p_lNbLines = 0; return 0; }
|
||||
if (pTextBox->p_stFormatRect == NULL) // NULL pointer to format rectangle
|
||||
{ *p_lNbLines = 0; return 0; }
|
||||
#endif
|
||||
|
||||
// Short cuts
|
||||
ulStyle = pTextBox->ulStyle;
|
||||
xTopRect = pTextBox->p_stFormatRect->tdsSommet[0].xY;
|
||||
xBottomRect = pTextBox->p_stFormatRect->tdsSommet[2].xY;
|
||||
pFont = pTextBox->p_stBFont;
|
||||
xHMax = (TDE_tdxValue)pFont->usHMax;
|
||||
xVAMax = (TDE_tdxValue)pFont->usVAMax;
|
||||
|
||||
// Is the format rectangle high enough for at least one line ?
|
||||
if ((xBottomRect-xTopRect) < (xVAMax+xHMax))
|
||||
{
|
||||
*p_lNbLines = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ulStyle & DT_VCENTER) // Vertically centered, single line
|
||||
{
|
||||
*p_lNbLines = 1;
|
||||
return ((xBottomRect + xTopRect + (xHMax + xVAMax)*0.5) * 0.5);
|
||||
}
|
||||
else if (ulStyle & DT_BOTTOM) // Bottom, single line
|
||||
{
|
||||
*p_lNbLines = 1;
|
||||
return (xBottomRect - xVAMax);
|
||||
}
|
||||
else // Top (default), either single or multiple line(s)
|
||||
{
|
||||
if (ulStyle & DT_SINGLELINE) // Single line
|
||||
*p_lNbLines = 1;
|
||||
else // Multiple lines
|
||||
*p_lNbLines = (xBottomRect-xTopRect)/(xVAMax+xHMax);
|
||||
return (xTopRect + xHMax);
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_xGetHorizontalOffset
|
||||
VERSION : 1.0 / Yan
|
||||
|
||||
AIM : Get the horizontal offset and the number of characters for the current line of a character string
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
TDE_tdxValue TDE_xGetHorizontalOffset (TDE_tdsTextBox *pTextBox, long lStartIndex, long *p_lEndIndex)
|
||||
{
|
||||
unsigned long ulStyle; // Format attributes
|
||||
TDE_tdxValue xLeftRect; // Left of the format rectangle
|
||||
TDE_tdxValue xRightRect; // Right of the format rectangle
|
||||
TDE_tdxValue xRectWidth; // Width of the format rectangle
|
||||
TDE_tdxValue xStrWidth; // Width of the text-line
|
||||
TDE_tdxValue xSpacing; // Horizontal spacing between two characters
|
||||
TDE_tdsBitmapFont *pFont; // Pointer to the bitmap font
|
||||
TDE_tdsBitmapLetter **pLetter; // Pointer to the array of pointers to bitmap letters
|
||||
char *pString; // Text string
|
||||
long i, j; // Counters
|
||||
unsigned char c; // Current char
|
||||
BOOL bIsThereABreakChar;
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_lNbChar == NULL) // NULL pointer to number of characters
|
||||
return 0;
|
||||
if (pTextBox == NULL) // NULL pointer to text box
|
||||
{ *p_lNbChar = 0; return 0; }
|
||||
if (pTextBox->eFontType != TDE_eFT_BITMAP) // Non-bitmap font
|
||||
{ *p_lNbChar = 0; return 0; }
|
||||
if (pTextBox->p_stBFont == NULL) // NULL pointer to bitmap font
|
||||
{ *p_lNbChar = 0; return 0; }
|
||||
if (pTextBox->p_stFormatRect == NULL) // NULL pointer to format rectangle
|
||||
{ *p_lNbChar = 0; return 0; }
|
||||
#endif
|
||||
|
||||
// Short cuts
|
||||
pFont = pTextBox->p_stBFont; // Pointer to the bitmap font
|
||||
pLetter = pFont->p_stMBLetter; // Pointer to the array of bitmap letters
|
||||
xSpacing = (TDE_tdxValue) pFont->usHorzSep; // Horizontal spacing between two characters
|
||||
pString = pTextBox->p_cText; // Text string
|
||||
ulStyle = pTextBox->ulStyle; // Format attributes
|
||||
xLeftRect = pTextBox->p_stFormatRect->tdsSommet[0].xX; // Left of format rectangle
|
||||
xRightRect = pTextBox->p_stFormatRect->tdsSommet[1].xX; // Right of format rectangle
|
||||
xRectWidth = xRightRect - xLeftRect + xSpacing; // Width of format rectangle
|
||||
xStrWidth = 0;
|
||||
// Loop through the string until it exceeds the rect width
|
||||
// or it is finished or there is a carriage return
|
||||
for (i=lStartIndex; (pString[i]!='\0') && // End of string
|
||||
(pString[i]!=13) && // Carriage return
|
||||
(xStrWidth<xRectWidth); i++)
|
||||
{
|
||||
// Get current character
|
||||
c = *((unsigned char *)(&pString[i])) - 32;
|
||||
// If it is defined, add its width and the horizontal spacing
|
||||
if (c < TDE_kNBLETTERS)
|
||||
if (pLetter[c])
|
||||
xStrWidth += pLetter[c]->stBLetter.p_stSprite->stDim.xX + xSpacing;
|
||||
}
|
||||
// If carriage return, take also the line feed
|
||||
if (pString[i] == 13)
|
||||
if (pString[i+1] == 10)
|
||||
i++;
|
||||
// If it exceeds the rect width, remove the last character
|
||||
if (xStrWidth>xRectWidth)
|
||||
{
|
||||
i--;
|
||||
if (c < TDE_kNBLETTERS)
|
||||
if (pLetter[c])
|
||||
xStrWidth -= pLetter[c]->stBLetter.p_stSprite->stDim.xX + xSpacing;
|
||||
}
|
||||
// If we must keep word's integrity, do it !
|
||||
if (ulStyle & DT_WORDBREAK)
|
||||
{
|
||||
// Look for a break char in the line
|
||||
// (if there is no break char, we can't process
|
||||
// DT_WORDBREAK)
|
||||
bIsThereABreakChar = FALSE;
|
||||
for (j=lStartIndex; j<i; j++)
|
||||
if (TDE_bIsBreakChar(pString[j]))
|
||||
bIsThereABreakChar = TRUE;
|
||||
// If there is at least one break char, process...
|
||||
if (bIsThereABreakChar)
|
||||
{
|
||||
// Remove characters of breaked word (if necessary)
|
||||
while (!TDE_bIsBreakChar(pString[i]))
|
||||
{
|
||||
i--;
|
||||
c = *((unsigned char *)(&pString[i])) - 32;
|
||||
if (c < TDE_kNBLETTERS)
|
||||
if (pLetter[c])
|
||||
xStrWidth -= pLetter[c]->stBLetter.p_stSprite->stDim.xX + xSpacing;
|
||||
}
|
||||
// Remove from the width (but not from the count)
|
||||
// spaces before end on line (if any)
|
||||
if (pLetter[' '])
|
||||
{
|
||||
for (j=1; (pString[i-j]==' ') && ((i-j)>lStartIndex); j++)
|
||||
{
|
||||
xStrWidth -= pLetter[' ']->stBLetter.p_stSprite->stDim.xX + xSpacing;
|
||||
}
|
||||
if ((i-j) == lStartIndex)
|
||||
if (pString[i-j]==' ')
|
||||
xStrWidth -= pLetter[' ']->stBLetter.p_stSprite->stDim.xX + xSpacing;
|
||||
}
|
||||
}
|
||||
// Add to the count (but not to the width) spaces after
|
||||
// end of line (if any)
|
||||
while (pString[i] == ' ') i++;
|
||||
}
|
||||
// Set number of characters
|
||||
*p_lEndIndex = i;
|
||||
// Compute horizontal offset
|
||||
if (ulStyle & DT_RIGHT)
|
||||
return (xRightRect - xStrWidth + xSpacing);
|
||||
else if (ulStyle & DT_CENTER)
|
||||
return xLeftRect + 0.5 * (xRectWidth - xStrWidth);
|
||||
else
|
||||
return xLeftRect;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawBitmapText
|
||||
VERSION : 2.0 / Yan
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Bitmap font rendering.
|
||||
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawBitmapText (GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsTextBox *pTextBox)
|
||||
{
|
||||
TDE_tdsBitmapFont *pFont; // Pointer to the bitmap font
|
||||
TDE_tdsBitmapLetter **pLetter; // Pointer to the array of pointers to bitmap letters
|
||||
long lNbLines; // Number of displayable lines
|
||||
long lCharIndex; // Char index in the string
|
||||
long lEndCharIndex; // Char index of end of current line in the string
|
||||
long lLineIndex; // Line index in the string
|
||||
char *pString; // Text string
|
||||
char cColorMode; // Color mode (normal or reverse)
|
||||
TDE_tdxValue xHOffset, xVOffset; // Horizontal and vertical offsets
|
||||
TDE_tdxValue xHSpacing; // Horizontal spacing between two characters
|
||||
TDE_tdxValue xHeightLine; // Height of a line
|
||||
TDE_tdxValue xHalfWidthChar; // Half of the width of current char
|
||||
TDE_tdeCursorType eCursorType; // Type of the cursor (insert, overwrite, no cursor)
|
||||
long lCursorIndex; // Position of the cursor in the string
|
||||
long i; // Counter
|
||||
unsigned char c; // Current character
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_stViewAttrib == NULL) // NULL pointer to viewport attributes
|
||||
return;
|
||||
if (pTextBox == NULL) // NULL pointer to text box
|
||||
return;
|
||||
if (pTextBox->eFontType != TDE_eFT_BITMAP) // Not a bitmap font
|
||||
return;
|
||||
if (pTextBox->p_stBFont == NULL) // NULL pointer to font
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Shortcuts
|
||||
pString = pTextBox->p_cText; // Pointer to the string
|
||||
if (pString == NULL) // Test if the string is NULL
|
||||
return;
|
||||
cColorMode = pTextBox->cColorMode; // Color mode (normal or reverse)
|
||||
lCursorIndex = pTextBox->lCursorPosition; // Cursor position
|
||||
eCursorType = pTextBox->eCursorType; // Cursor type
|
||||
pFont = pTextBox->p_stBFont; // Pointer to the font
|
||||
pLetter = pFont->p_stMBLetter; // Pointer to the array of bitmap letters
|
||||
xHSpacing = (TDE_tdxValue) pFont->usHorzSep; // Horizontal spacing between two characters
|
||||
xHeightLine = (TDE_tdxValue) (pFont->usVertSep + pFont->usHMax + pFont->usVAMax); // Height of a line
|
||||
// Initialize the index at the beginning of the string
|
||||
lCharIndex = 0;
|
||||
|
||||
// Compute initial vertical offset
|
||||
xVOffset = TDE_xGetVerticalOffset (pTextBox, &lNbLines);
|
||||
|
||||
// Loop on the displayable lines (while the string is not terminated)
|
||||
for (lLineIndex=0; (lLineIndex<lNbLines) && (pString[lCharIndex]!='\0'); lLineIndex++)
|
||||
{
|
||||
// Compute initial horizontal offset for the current line
|
||||
xHOffset = TDE_xGetHorizontalOffset (pTextBox, lCharIndex, &lEndCharIndex);
|
||||
// Loop on the characters of the current line
|
||||
for (i=lCharIndex; i<lEndCharIndex; i++)
|
||||
{
|
||||
// Get current character
|
||||
c = *((unsigned char *)(&pString[i])) - 32;
|
||||
// If the current character is defined
|
||||
if (c < TDE_kNBLETTERS)
|
||||
if (pLetter[c])
|
||||
{
|
||||
// Compute the half of the width of the char
|
||||
xHalfWidthChar = (pLetter[c]->stBLetter.p_stSprite->stDim.xX) * 0.5;
|
||||
// Move horizontally to the center of the letter
|
||||
xHOffset += xHalfWidthChar;
|
||||
// Set coordinates of the center of the letter
|
||||
pLetter[c]->stBLetter.stModifiedMatrix.stTranslateVertex.xX = xHOffset;
|
||||
pLetter[c]->stBLetter.stModifiedMatrix.stTranslateVertex.xY = xVOffset -
|
||||
0.5*(pLetter[c]->stBLetter.p_stSprite->stDim.xY) +
|
||||
(TDE_tdxValue)(pLetter[c]->usVAlign);
|
||||
// Different cases depending on the type of cursor
|
||||
switch (eCursorType)
|
||||
{
|
||||
// No cursor
|
||||
case TDE_eCT_NOCURSOR:
|
||||
// Draw the character the normal way
|
||||
if (cColorMode == 0) // Normal color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsolute
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
else // Negative color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsoluteInvert
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
break;
|
||||
// Draw overwrite cursor
|
||||
case TDE_eCT_OVERWRITE:
|
||||
// If the current position is the position of the cursor...
|
||||
if (i == lCursorIndex)
|
||||
{
|
||||
// If the flicking state is set as 'show'...
|
||||
if (TDE_g_cFlick)
|
||||
{
|
||||
// Draw the character inverted and without transparency
|
||||
pLetter[c]->stBLetter.p_stSprite->c_NZ = 0;
|
||||
TDE_vFastDrawMemorySpriteAbsoluteInvert
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
pLetter[c]->stBLetter.p_stSprite->c_NZ = 1;
|
||||
}
|
||||
// If the flicking state is set as 'hide'...
|
||||
else
|
||||
{
|
||||
// Draw the character the normal way
|
||||
TDE_vFastDrawMemorySpriteAbsolute
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
}
|
||||
// If the current position is not the position of the cursor,
|
||||
else
|
||||
{
|
||||
// Draw the character the normal way
|
||||
if (cColorMode == 0) // Normal color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsolute
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
else // Negative color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsoluteInvert
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Draw insert cursor
|
||||
case TDE_eCT_INSERT:
|
||||
// Draw the character the normal way
|
||||
if (cColorMode == 0) // Normal color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsolute
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
else // Negative color mode
|
||||
{
|
||||
TDE_vFastDrawMemorySpriteAbsoluteInvert
|
||||
(p_stViewAttrib, &(pLetter[c]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
// If the current position is the position of the cursor...
|
||||
if (i == lCursorIndex)
|
||||
{
|
||||
// If the flicking state is set as 'show'...
|
||||
if (TDE_g_cFlick)
|
||||
{
|
||||
// Set coordinates of the insert cursor
|
||||
pLetter[TDE_kINSERTCURSOR]->stBLetter.stModifiedMatrix.stTranslateVertex.xX
|
||||
= xHOffset - xHalfWidthChar;
|
||||
pLetter[TDE_kINSERTCURSOR]->stBLetter.stModifiedMatrix.stTranslateVertex.xY
|
||||
= xVOffset - 0.5*(pLetter[TDE_kINSERTCURSOR]->stBLetter.p_stSprite->stDim.xY) +
|
||||
(TDE_tdxValue)(pLetter[TDE_kINSERTCURSOR]->usVAlign);
|
||||
// Draw the insert cursor
|
||||
TDE_vFastDrawMemorySpriteAbsolute
|
||||
(p_stViewAttrib, &(pLetter[TDE_kINSERTCURSOR]->stBLetter), pTextBox->p_stClipRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
// Move horizontally to the beginning of next letter
|
||||
xHOffset += xHalfWidthChar + xHSpacing;
|
||||
} // if the current character is defined
|
||||
} // loop on the characters in the current line
|
||||
// Update current character-index and vertical offset
|
||||
lCharIndex = lEndCharIndex;
|
||||
xVOffset += xHeightLine;
|
||||
} // loop on each line
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawBitmapTextWithRectAdjustment
|
||||
VERSION : 2.0 / Yan
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Set the height of a format rect depending on what you want to put into ....
|
||||
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vTDE_vAdjustTextBoxFormatRect( TDE_tdsTextBox *pTextBox)
|
||||
{
|
||||
TDE_tdsBitmapFont *pFont; // Pointer to the bitmap font
|
||||
long lNbLines; // Number of displayable lines
|
||||
long lCharIndex; // Char index in the string
|
||||
long lEndCharIndex; // Char index of end of current line in the string
|
||||
char *pString; // Text string
|
||||
TDE_tdxValue xHOffset;
|
||||
TDE_tdxValue xHeightLine; // Height of a line
|
||||
long lTextLenght;
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_stViewAttrib == NULL) // NULL pointer to viewport attributes
|
||||
return;
|
||||
if (pTextBox == NULL) // NULL pointer to text box
|
||||
return;
|
||||
if (pTextBox->eFontType != TDE_eFT_BITMAP) // Not a bitmap font
|
||||
return;
|
||||
if (pTextBox->p_stBFont == NULL) // NULL pointer to font
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Shortcuts
|
||||
pString = pTextBox->p_cText; // Pointer to the string
|
||||
if (pString == NULL) // Test if the string is NULL
|
||||
return;
|
||||
lTextLenght = strlen(pString);
|
||||
if ( lTextLenght == 0 )
|
||||
return;
|
||||
|
||||
pFont = pTextBox->p_stBFont; // Pointer to the font
|
||||
xHeightLine = (TDE_tdxValue) (pFont->usVertSep + pFont->usHMax + pFont->usVAMax); // Height of a line
|
||||
lCharIndex = 0;
|
||||
lNbLines = 0;
|
||||
|
||||
do
|
||||
{
|
||||
// Compute initial horizontal offset for the current line
|
||||
xHOffset = TDE_xGetHorizontalOffset (pTextBox, lCharIndex, &lEndCharIndex);
|
||||
// Update current character-index and vertical offset
|
||||
lCharIndex = lEndCharIndex;
|
||||
lNbLines++;
|
||||
|
||||
}while ( lEndCharIndex<lTextLenght );
|
||||
|
||||
pTextBox->p_stFormatRect->tdsSommet[2].xY = pTextBox->p_stFormatRect->tdsSommet[0].xY + (lNbLines*xHeightLine);
|
||||
pTextBox->p_stFormatRect->tdsSommet[3].xY = pTextBox->p_stFormatRect->tdsSommet[2].xY;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawTrueTypeText
|
||||
VERSION : 2.0 / Yan
|
||||
1.0 / Franck
|
||||
|
||||
AIM : True type font rendering.
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawTrueTypeText (GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsTextBox *pTextBox)
|
||||
{
|
||||
char *pString; // Text string
|
||||
TDE_tdsRect *pFormatRect; // Pointer to format rectangle (TDE structure)
|
||||
TDE_tdsRect *pClipRect; // Pointer to clipping rectangle (TDE structure)
|
||||
RECT stFormatRect; // Format rectangle (WINDOWS structure)
|
||||
RECT stClipRect; // Clipping rectangle (WINDOWS structure)
|
||||
LPDIRECTDRAWSURFACE lpBackSurf; // Direct draw surface on which we must draw
|
||||
HDC hdc = NULL; // Handle to DC (Display Context)
|
||||
TDE_tdsTrueTypeFont *pFont; // Pointer to the true type font
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_stViewAttrib == NULL) // NULL pointer to viewport attributes
|
||||
return;
|
||||
if (pTextBox == NULL) // NULL pointer to text box
|
||||
return;
|
||||
if (pTextBox->eFontType != TDE_eFT_TRUETYPE)// Not a true type font
|
||||
return;
|
||||
if (pTextBox->p_stTFont == NULL) // NULL pointer to font
|
||||
return;
|
||||
if (pTextBox->p_stFormatRect == NULL) // NULL pointer to format rectangle
|
||||
return;
|
||||
if (pTextBox->p_stClipRect == NULL) // NULL pointer to clipping rectangle
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Pointer to the string
|
||||
pString = pTextBox->p_cText; // Pointer to the string
|
||||
if (pString == NULL) // Test if the string is NULL
|
||||
return;
|
||||
pFont = pTextBox->p_stTFont;
|
||||
// Format rectangle
|
||||
pFormatRect = pTextBox->p_stFormatRect;
|
||||
stFormatRect.top = (long) pFormatRect->tdsSommet[0].xY;
|
||||
stFormatRect.bottom = (long) pFormatRect->tdsSommet[2].xY;
|
||||
stFormatRect.left = (long) pFormatRect->tdsSommet[0].xX;
|
||||
stFormatRect.right = (long) pFormatRect->tdsSommet[1].xX;
|
||||
// Clipping rectangle
|
||||
pClipRect = pTextBox->p_stClipRect;
|
||||
stClipRect.top = (long) pClipRect->tdsSommet[0].xY;
|
||||
stClipRect.bottom = (long) pClipRect->tdsSommet[2].xY;
|
||||
stClipRect.left = (long) pClipRect->tdsSommet[0].xX;
|
||||
stClipRect.right = (long) pClipRect->tdsSommet[1].xX;
|
||||
// Get DC
|
||||
lpBackSurf = (LPDIRECTDRAWSURFACE)p_stViewAttrib->p_vReserved;
|
||||
IDirectDrawSurface_GetDC(lpBackSurf, &hdc);
|
||||
if (!hdc) return;
|
||||
// Set boundaries
|
||||
// SetBoundsRect (hdc, &stClipRect, DCB_RESET|DCB_ACCUMULATE);
|
||||
// Configure the DC to render text
|
||||
SetMapMode (hdc, MM_TEXT);
|
||||
SetBkMode (hdc, TRANSPARENT);
|
||||
// Select the font
|
||||
SelectObject (hdc, (HGDIOBJ)pFont->hFont);
|
||||
// Select the color
|
||||
if (pTextBox->cColorMode == 0) // Normal color mode
|
||||
SetTextColor (hdc, pFont->lColor);
|
||||
else // Reverse color mode
|
||||
SetTextColor (hdc, ~(pFont->lColor));
|
||||
// Let Windows do the job for us
|
||||
DrawText (hdc, pTextBox->p_cText, -1, &stFormatRect, pTextBox->ulStyle);
|
||||
// Release DC
|
||||
IDirectDrawSurface_ReleaseDC(lpBackSurf, hdc);
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDrawTextInABox
|
||||
VERSION : 2.0 / Yan
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Display a text in a box.
|
||||
Formatting flags :
|
||||
DT_BOTTOM
|
||||
DT_CENTER
|
||||
DT_LEFT
|
||||
DT_RIGHT
|
||||
DT_SINGLELINE
|
||||
DT_TOP
|
||||
DT_VCENTER
|
||||
DT_WORDBREAK
|
||||
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDrawTextInABox (GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsSuperObject *p_stSuperObject,
|
||||
BOOL bViewPortLocked)
|
||||
{
|
||||
TDE_tdsTextBox *pTextBox; // Pointer to the text box
|
||||
|
||||
#ifdef TDE_DEBUG
|
||||
// Tests for reliability
|
||||
if (p_stSuperObject == NULL) // NULL pointer to super object
|
||||
return;
|
||||
if (p_stViewAttrib == NULL) // NULL pointer to viewport attributes
|
||||
return;
|
||||
if (p_stSuperObject->eType != TDE_eOT_TEXTBOX) // The super object is not a text box
|
||||
return;
|
||||
if (p_stSuperObject->p_stTextBox == NULL) // NULL pointer to text box
|
||||
return;
|
||||
#endif
|
||||
|
||||
pTextBox = p_stSuperObject->p_stTextBox;
|
||||
switch (pTextBox->eFontType)
|
||||
{
|
||||
case TDE_eFT_BITMAP:
|
||||
if (bViewPortLocked) // Viewport must be locked
|
||||
TDE_vDrawBitmapText (p_stViewAttrib, pTextBox);
|
||||
break;
|
||||
case TDE_eFT_TRUETYPE:
|
||||
if (!bViewPortLocked) // Viewport must not be locked
|
||||
TDE_vDrawTrueTypeText (p_stViewAttrib, pTextBox);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
644
Rayman_X/cpa/tempgrp/TDE/tde_files.c
Normal file
644
Rayman_X/cpa/tempgrp/TDE/tde_files.c
Normal file
@@ -0,0 +1,644 @@
|
||||
// ReadMbm.c
|
||||
// Slightly modified by Yan...
|
||||
|
||||
#include "tde.h"
|
||||
|
||||
#define RedOn6bits 0
|
||||
#define GreenOn6bits 1
|
||||
#define BlueOn6bits 0
|
||||
|
||||
ACP_tdxBool TDE_g_bRedOn6bits;
|
||||
ACP_tdxBool TDE_g_bGreenOn6bits;
|
||||
ACP_tdxBool TDE_g_bBlueOn6bits;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_vSetRGBFormat
|
||||
// Set the RGB format
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDE_vSetRGBFormat ( ACP_tdxBool bRedOn6bits, ACP_tdxBool bGreenOn6bits, ACP_tdxBool bBlueOn6bits )
|
||||
{
|
||||
TDE_g_bRedOn6bits = bRedOn6bits;
|
||||
TDE_g_bGreenOn6bits = bGreenOn6bits;
|
||||
TDE_g_bBlueOn6bits = bBlueOn6bits;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_lReadMBMData
|
||||
// Reads the MBM data from an opened file and convert them into the right
|
||||
// format according to the video board.
|
||||
// Return 1 if OK, 0 if Failed.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long TDE_lReadMBMData (FILE *pFile, TDE_tdsSprite *p_stSprite)
|
||||
{
|
||||
// Local variables
|
||||
size_t nbBlocks;
|
||||
unsigned short sPictureWidth, sPictureHeight, sMagicColor;
|
||||
unsigned short R, G, B, c555;
|
||||
TDE_tdxPixel *Buffer, *TempBuff;
|
||||
unsigned long usI, usLine, lPicSize;
|
||||
BOOL bTransparent;
|
||||
|
||||
//**********************************************************
|
||||
// Read the data
|
||||
//**********************************************************
|
||||
|
||||
// Read the Width
|
||||
nbBlocks = fread( &sPictureWidth, sizeof(short), 1, pFile);
|
||||
if (nbBlocks != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
// Read the Height
|
||||
nbBlocks = fread( &sPictureHeight, sizeof(short), 1, pFile);
|
||||
if (nbBlocks != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
// Read the magic color
|
||||
nbBlocks = fread( &sMagicColor, sizeof(short), 1, pFile);
|
||||
if (nbBlocks != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
// Compute the size of the picture (in pixels)
|
||||
lPicSize = (long)(sPictureHeight) * (long)(sPictureWidth);
|
||||
// Allocate memory for temporary buffer and for definitive buffer
|
||||
M_TdeAlloc(Buffer,TDE_tdxPixel *,(sizeof(short)*lPicSize));
|
||||
if (Buffer == NULL)
|
||||
return 0;
|
||||
M_TdeAlloc(TempBuff,TDE_tdxPixel *,(sizeof(short)*lPicSize));
|
||||
if (TempBuff == NULL)
|
||||
{
|
||||
M_TdeFree (Buffer);
|
||||
return 0;
|
||||
}
|
||||
// Read the data
|
||||
nbBlocks = fread( TempBuff, sizeof(short), lPicSize, pFile);
|
||||
if (nbBlocks != lPicSize)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//**********************************************************
|
||||
// Convert the data
|
||||
//**********************************************************
|
||||
|
||||
// Let's assume the bitmap isn't transparent
|
||||
bTransparent = FALSE;
|
||||
|
||||
// 555 -> 565
|
||||
if (TDE_g_bGreenOn6bits)
|
||||
{
|
||||
// Magic color
|
||||
R = (sMagicColor&0x7C00)>>10;
|
||||
G = (sMagicColor&0x3E0)>>5;
|
||||
B = sMagicColor&0x1F;
|
||||
sMagicColor = (R<<11) + (G<<6) + B;
|
||||
// Loop on each line
|
||||
for ( usLine=0; usLine<lPicSize; usLine+=sPictureWidth )
|
||||
{
|
||||
// Loop on each point
|
||||
for ( usI=0; usI<sPictureWidth; usI++ )
|
||||
{
|
||||
// Get the original color
|
||||
c555 = TempBuff[lPicSize - usLine - sPictureWidth + usI];
|
||||
// If it is not transparent, convert it
|
||||
if (c555&&0x8000)
|
||||
{
|
||||
R = (c555&0x7C00)>>10;
|
||||
G = (c555&0x3E0)>>5;
|
||||
B = c555&0x1F;
|
||||
Buffer[usLine + usI] = (R<<11) + (G<<6) + B;
|
||||
}
|
||||
// If it is transparent, set it to the magic color
|
||||
else
|
||||
{
|
||||
bTransparent = TRUE;
|
||||
Buffer[usLine + usI] = sMagicColor;
|
||||
}
|
||||
} // for (usI....
|
||||
} // for (us Line ....
|
||||
}
|
||||
// 555 -> 556
|
||||
else if (TDE_g_bBlueOn6bits)
|
||||
{
|
||||
// Magic color
|
||||
R = (sMagicColor&0x7C00)>>10;
|
||||
G = (sMagicColor&0x3E0)>>5;
|
||||
B = sMagicColor&0x1F;
|
||||
sMagicColor = (R<<11) + (G<<6) + (B<<1);
|
||||
// Loop on each line
|
||||
for ( usLine=0; usLine<(sPictureHeight*sPictureWidth); usLine+=sPictureWidth )
|
||||
{
|
||||
// Loop on each point
|
||||
for ( usI=0; usI<sPictureWidth; usI++ )
|
||||
{
|
||||
// Get the original color
|
||||
c555 = TempBuff[lPicSize - usLine - sPictureWidth + usI];
|
||||
// If it is not transparent, convert it
|
||||
if (c555&&0x8000)
|
||||
{
|
||||
R = (c555&0x7C00)>>10;
|
||||
G = (c555&0x3E0)>>5;
|
||||
B = c555&0x1F;
|
||||
Buffer[usLine + usI] = (R<<11) + (G<<5) + (B<<1);
|
||||
}
|
||||
// If it is transparent, set it to the magic color
|
||||
else
|
||||
{
|
||||
bTransparent = TRUE;
|
||||
Buffer[usLine + usI] = sMagicColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 555 -> 655
|
||||
else if (TDE_g_bRedOn6bits)
|
||||
{
|
||||
// Magic color
|
||||
R = (sMagicColor&0x7C00)>>10;
|
||||
G = (sMagicColor&0x3E0)>>5;
|
||||
B = sMagicColor&0x1F;
|
||||
sMagicColor = (R<<11) + (G<<5) + B;
|
||||
// Loop on each line
|
||||
for ( usLine=0; usLine<(sPictureHeight*sPictureWidth); usLine+=sPictureWidth )
|
||||
{
|
||||
// Loop on each point
|
||||
for ( usI=0; usI<sPictureWidth; usI++ )
|
||||
{
|
||||
// Get the original color
|
||||
c555 = TempBuff[lPicSize - usLine - sPictureWidth + usI];
|
||||
// If it is not transparent, convert it
|
||||
if (c555&&0x8000)
|
||||
{
|
||||
R = (c555&0x7C00)>>10;
|
||||
G = (c555&0x3E0)>>5;
|
||||
B = c555&0x1F;
|
||||
Buffer[usLine + usI] = (R<<11) + (G<<5) + B;
|
||||
}
|
||||
// If it is transparent, set it to the magic color
|
||||
else
|
||||
{
|
||||
bTransparent = TRUE;
|
||||
Buffer[usLine + usI] = sMagicColor;
|
||||
}
|
||||
} // for (usI...
|
||||
} // for (usLine...
|
||||
} // if
|
||||
// 555 -> 555
|
||||
else
|
||||
{
|
||||
// Loop on each line
|
||||
for ( usLine=0; usLine<(sPictureHeight*sPictureWidth); usLine+=sPictureWidth )
|
||||
{
|
||||
// Loop on each point
|
||||
for ( usI=0; usI<sPictureWidth; usI++ )
|
||||
{
|
||||
// Get the original color
|
||||
c555 = TempBuff[lPicSize - usLine - sPictureWidth + usI];
|
||||
// If it is not transparent, convert it
|
||||
if (c555&&0x8000)
|
||||
{
|
||||
Buffer[usLine + usI] = c555;
|
||||
}
|
||||
// If it is transparent, set it to the magic color
|
||||
else
|
||||
{
|
||||
bTransparent = TRUE;
|
||||
Buffer[usLine + usI] = sMagicColor;
|
||||
}
|
||||
} // for (usI...
|
||||
} // for (usLine...
|
||||
}
|
||||
// Free the temporary buffer
|
||||
M_TdeFree(TempBuff);
|
||||
// Set the members of the sprite structure
|
||||
p_stSprite->stDim.xX = sPictureWidth;
|
||||
p_stSprite->stDim.xY = sPictureHeight;
|
||||
p_stSprite->xMagicColor = sMagicColor;
|
||||
p_stSprite->v_pData = Buffer;
|
||||
// Set transparency
|
||||
if (bTransparent)
|
||||
p_stSprite->c_NZ = 1;
|
||||
else
|
||||
p_stSprite->c_NZ = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_lReadAndConvertMBMFile
|
||||
// Read a MBM file (open and close it).
|
||||
// Returns 1 if OK, 0 if FAILED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long TDE_lReadAndConvertMBMFile(char *filename, TDE_tdsSprite *p_stSprite)
|
||||
{
|
||||
FILE *pFile;
|
||||
|
||||
// Open the file
|
||||
if ( (pFile = fopen(filename, "rb")) != NULL )
|
||||
{
|
||||
fseek (pFile, 0, SEEK_SET);
|
||||
// Read it and convert the data
|
||||
if (!TDE_lReadMBMData (pFile, p_stSprite))
|
||||
{
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
fclose (pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantOpenFileForReading,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_lReadCursorAnimation
|
||||
// Read cursor animation in a text file
|
||||
// Returns 1 if OK
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long TDE_lReadCursorAnimation (char *szDir, char *szTxtFile, TDE_tdsAnimatedCursor *Anim)
|
||||
{
|
||||
FILE *pFile;
|
||||
char text[30];
|
||||
int NB_STEP, i;
|
||||
TDE_p_stAnimatedCursor Next;
|
||||
char szFilename[100];
|
||||
|
||||
// Obtain txt filename with path
|
||||
strcpy (szFilename, szDir);
|
||||
strcat (szFilename, szTxtFile);
|
||||
|
||||
// Open txt file
|
||||
if ( (pFile = fopen(szFilename, "r")) != NULL )
|
||||
{
|
||||
fseek (pFile, 0, SEEK_SET);
|
||||
// Number of sprites
|
||||
if (!fgets (text, 30, pFile))
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
NB_STEP = atoi(text);
|
||||
// Active point coordinates
|
||||
if (!fgets(text, 30, pFile))
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
Anim->stActiveCoordinates.xX = atof(text);
|
||||
if (!fgets(text, 30, pFile))
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
Anim->stActiveCoordinates.xY = atof(text);
|
||||
// First step
|
||||
Anim->Step.v_pData = NULL;
|
||||
Anim->Step.c_NZ = 1;
|
||||
Anim->Step.cFlip = 0;
|
||||
Anim->Step.cSemiTransparent = 0;
|
||||
if (!fscanf (pFile, "%s", text))
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// Obtain MBM filename with path
|
||||
strcpy (szFilename, szDir);
|
||||
strcat (szFilename, text);
|
||||
// Read MBM file
|
||||
if (!TDE_lReadAndConvertMBMFile(szFilename, &(Anim->Step)))
|
||||
{
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
Next = Anim;
|
||||
|
||||
for ( i=0; i<NB_STEP; i++ )
|
||||
{
|
||||
M_TdeAlloc(Next->Next, TDE_tdsAnimatedCursor *, (sizeof(TDE_tdsAnimatedCursor)));
|
||||
Next = Next->Next;
|
||||
if (Next == NULL)
|
||||
{
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
Next->Next = NULL;
|
||||
Next->Step.v_pData = NULL;
|
||||
Next->Step.c_NZ = 1;
|
||||
Next->Step.cFlip = 0;
|
||||
Next->Step.cSemiTransparent = 0;
|
||||
if (!fscanf (pFile, "%s", text))
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// Obtain MBM filename with path
|
||||
strcpy (szFilename, szDir);
|
||||
strcat (szFilename, text);
|
||||
// Read MBM file
|
||||
if (!TDE_lReadAndConvertMBMFile(szFilename, &(Next->Step)))
|
||||
{
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
fclose (pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantOpenFileForReading,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_vDestroyAnimatedCursor
|
||||
// Aim : Destroy animated cursor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDE_vDestroyAnimatedCursor(TDE_tdsAnimatedCursor *Anim)
|
||||
{
|
||||
TDE_p_stAnimatedCursor Last, Previous;
|
||||
|
||||
if ( Anim == NULL)
|
||||
return;
|
||||
|
||||
while (Anim->Next != NULL)
|
||||
{
|
||||
Last = Anim->Next;
|
||||
Previous = Anim;
|
||||
while (Last->Next != NULL)
|
||||
{
|
||||
Previous = Last;
|
||||
Last = Last->Next;
|
||||
}
|
||||
if (Last->Step.v_pData)
|
||||
M_TdeFree (Last->Step.v_pData);
|
||||
M_TdeFree (Last);
|
||||
Previous->Next = NULL;
|
||||
}
|
||||
if (Anim->Step.v_pData)
|
||||
M_TdeFree (Anim->Step.v_pData);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_lReadMBFFile
|
||||
// Read a MBF file (font file)
|
||||
// File structure :
|
||||
// 224 character definitions, ASCII codes from 32 to 255
|
||||
// Returns 1 if OK, 0 if failed
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long TDE_lReadMBFFile(char *filename, TDE_tdsBitmapFont *BFont)
|
||||
{
|
||||
// Local variables
|
||||
FILE *pFile;
|
||||
unsigned short VAlign;
|
||||
short i;
|
||||
TDE_tdsBitmapLetter *pLetter;
|
||||
TDE_tdsSprite *p_Spr;
|
||||
unsigned short H, HMax = 0;
|
||||
unsigned short VAMax = 0;
|
||||
unsigned short HorzSep, VertSep;
|
||||
|
||||
// First initialize every characters to NULL
|
||||
for ( i=0; i<TDE_kNBLETTERS; i++ )
|
||||
{
|
||||
BFont->p_stMBLetter[i] = NULL;
|
||||
}
|
||||
// Open the file
|
||||
if ( (pFile = fopen(filename, "rb")) != NULL )
|
||||
{
|
||||
fseek( pFile, 0, SEEK_SET );
|
||||
// Loop on each character
|
||||
for ( i=0; i<TDE_kNBLETTERS; i++ )
|
||||
{
|
||||
// Read the vertical alignment
|
||||
if (fread(&VAlign, sizeof(unsigned short), 1, pFile) != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// If the character is defined
|
||||
if ( VAlign != 0x8000 )
|
||||
{
|
||||
// SuperObject memory allocation
|
||||
M_TdeAlloc (pLetter, TDE_tdsBitmapLetter *, sizeof(TDE_tdsBitmapLetter));
|
||||
if (pLetter == NULL)
|
||||
return 0;
|
||||
pLetter->usVAlign = VAlign;
|
||||
|
||||
// SuperObject initialisation
|
||||
pLetter->stBLetter.sPriority = 40;
|
||||
pLetter->stBLetter.p_stChild = NULL;
|
||||
pLetter->stBLetter.p_stLeftBrother = NULL;
|
||||
pLetter->stBLetter.p_stRightBrother = NULL;
|
||||
pLetter->stBLetter.p_stFather = NULL;
|
||||
pLetter->stBLetter.eType = TDE_eOT_SPRITE;
|
||||
pLetter->stBLetter.stMatrix.xAngle = 0;
|
||||
pLetter->stBLetter.stMatrix.stScale.xX = 0;
|
||||
pLetter->stBLetter.stMatrix.stScale.xY = 0;
|
||||
pLetter->stBLetter.stMatrix.stTranslateVertex.xX = 0;
|
||||
pLetter->stBLetter.stMatrix.stTranslateVertex.xY = 0;
|
||||
pLetter->stBLetter.p_stSOClipRect = NULL;
|
||||
pLetter->stBLetter.lArea = 0xFFFFFFFF;
|
||||
pLetter->stBLetter.lObject = 0xFFFFFFFF;
|
||||
|
||||
// Sprite allocation and initialization
|
||||
TDE_vInitMemSprite( &(pLetter->stBLetter), NULL, 1);
|
||||
p_Spr = pLetter->stBLetter.p_stSprite;
|
||||
if (p_Spr == NULL)
|
||||
{
|
||||
M_TdeFree (pLetter);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// Read MBM bitmap
|
||||
if (!TDE_lReadMBMData (pFile, p_Spr))
|
||||
{
|
||||
TDE_vReleaseMemSprite (p_Spr);
|
||||
M_TdeFree (pLetter);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// HMax & VAMax
|
||||
if (pLetter->usVAlign > VAMax)
|
||||
VAMax = pLetter->usVAlign;
|
||||
H = p_Spr->stDim.xY - pLetter->usVAlign;
|
||||
if (H>HMax)
|
||||
HMax = H;
|
||||
// Set character
|
||||
BFont->p_stMBLetter[i] = pLetter;
|
||||
}
|
||||
else
|
||||
{
|
||||
BFont->p_stMBLetter[i] = NULL;
|
||||
}
|
||||
}
|
||||
// Read Horizontal spacing (default:3)
|
||||
if (fread( &HorzSep, sizeof(short), 1, pFile) != 1)
|
||||
HorzSep = 3;
|
||||
// Read Vertical spacing (default:3)
|
||||
if (fread( &VertSep, sizeof(short), 1, pFile) != 1)
|
||||
VertSep = 3;
|
||||
// Set global members
|
||||
BFont->usHorzSep = HorzSep;
|
||||
BFont->usVertSep = VertSep;
|
||||
BFont->usVAMax = VAMax;
|
||||
BFont->usHMax = HMax;
|
||||
// Close the file
|
||||
fclose(pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantOpenFileForReading,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TDE_lReadMTFFile
|
||||
// Read a MTF file (open and close it).
|
||||
// Returns 1 if OK, 0 if FAILED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long TDE_lReadMTFFile(char *filename, TDE_tdsTrueTypeFont *pFont)
|
||||
{
|
||||
FILE *pFile;
|
||||
LOGFONT stLogFont;
|
||||
COLORREF lColor;
|
||||
HFONT hFont;
|
||||
|
||||
// Open the file
|
||||
if ( (pFile = fopen(filename, "rb")) != NULL )
|
||||
{
|
||||
fseek (pFile, 0, SEEK_SET);
|
||||
// Read the LOGFONT structure
|
||||
if (fread(&stLogFont, sizeof(LOGFONT), 1, pFile) != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
// Read the COLORREF
|
||||
if (fread(&lColor, sizeof(COLORREF), 1, pFile) != 1)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantReadFile,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
fclose (pFile);
|
||||
return 0;
|
||||
}
|
||||
fclose (pFile);
|
||||
// Create the Windows font
|
||||
hFont = CreateFont
|
||||
(stLogFont.lfHeight, stLogFont.lfWidth, stLogFont.lfEscapement,
|
||||
stLogFont.lfOrientation, stLogFont.lfWeight, stLogFont.lfItalic,
|
||||
stLogFont.lfUnderline, stLogFont.lfStrikeOut, stLogFont.lfCharSet,
|
||||
stLogFont.lfOutPrecision, stLogFont.lfClipPrecision, stLogFont.lfQuality,
|
||||
stLogFont.lfPitchAndFamily, stLogFont.lfFaceName);
|
||||
if (hFont == NULL)
|
||||
return 0;
|
||||
// Set the members of the structure
|
||||
pFont->hFont = hFont;
|
||||
pFont->lColor = lColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningCantOpenFileForReading,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
987
Rayman_X/cpa/tempgrp/TDE/tde_init.c
Normal file
987
Rayman_X/cpa/tempgrp/TDE/tde_init.c
Normal file
@@ -0,0 +1,987 @@
|
||||
/**************************************************************************************
|
||||
|
||||
File : INIT.CPP
|
||||
Author : Delattre Franck & Val<61>rie Cluzel
|
||||
Last update : 21 / 02 / 97
|
||||
|
||||
Three types of functions:
|
||||
- Initialization functions
|
||||
- functions used to change a field
|
||||
- liberation functions
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
#define TDE_GLOBALS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define __DeclareGlobalVariableErrTde_h__
|
||||
#include "TDE\errtde.h"
|
||||
#undef __DeclareGlobalVariableErrTde_h__
|
||||
|
||||
#define __DeclareGlobalVariableMmgTde_h__
|
||||
#include "TDE\mmgtde.h"
|
||||
#undef __DeclareGlobalVariableMmgTde_h__
|
||||
|
||||
#include "TDE.h"
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
TDE_INIT.C
|
||||
First part : INITIALIZATION FUNCTIONS
|
||||
|
||||
- TDE_vInitPictureAttributes
|
||||
- TDE_vInitCamera
|
||||
- TDE_vInitSuperObject
|
||||
- TDE_vInitSuperObjectWithSprite
|
||||
- TDE_vInitLine
|
||||
- TDE_vInitSprite
|
||||
- TDE_vInitMemSprite
|
||||
- TDE_vInitMemSpriteWithoutSO
|
||||
- TDE_vInitTextBox
|
||||
- TDE_vCreateBitmapFont
|
||||
- TDE_vCreateTrueTypeFont
|
||||
- TDE_vInitTransparencyTable
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitPictureAttributes
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a TDE_tdsPictureAttributes structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitPictureAttributes(TDE_tdsPictureAttributes **h_stPicture,
|
||||
TDE_tdxValue xWidth,
|
||||
TDE_tdxValue xHeight,
|
||||
TDE_tdxValue xSrcPitch,
|
||||
TDE_tdLP_SOURCE lp_Data,
|
||||
TDE_tdLP_SURF lp_DDS)
|
||||
{
|
||||
M_TdeAlloc( (*h_stPicture), TDE_tdsPictureAttributes *, (sizeof(TDE_tdsPictureAttributes)) );
|
||||
if ((*h_stPicture) == NULL)
|
||||
return;
|
||||
(*h_stPicture)->xWidth = xWidth;
|
||||
(*h_stPicture)->xHeight = xHeight;
|
||||
(*h_stPicture)->xSrcPitch = xSrcPitch;
|
||||
(*h_stPicture)->lp_Data = lp_Data;
|
||||
(*h_stPicture)->lp_DDS = lp_DDS;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitCamera
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Initialize the camera
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitCamera(TDE_tdsCamera *stCamera)
|
||||
{
|
||||
stCamera->xAngle = 0;
|
||||
stCamera->stScale.xX = 1;
|
||||
stCamera->stScale.xY = 1;
|
||||
stCamera->stTranslateVertex.xX = 0;
|
||||
stCamera->stTranslateVertex.xY = 0;
|
||||
TDE_vCreateSuperObjectMatrix(stCamera);
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitSuperObject
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a TDE_tdsSuperObject structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitSuperObject(TDE_tdsSuperObject **h_stSuperObject,
|
||||
short sPriority,
|
||||
TDE_tdsSuperObject *p_stChild,
|
||||
TDE_tdsSuperObject *p_stLeftBrother,
|
||||
TDE_tdsSuperObject *p_stRightBrother,
|
||||
TDE_tdsSuperObject *p_stFather,
|
||||
TDE_tdeType eType,
|
||||
TDE_tdxAngle xAngle,
|
||||
TDE_tdxValue xZX,
|
||||
TDE_tdxValue xZY,
|
||||
TDE_tdxValue xCenterX,
|
||||
TDE_tdxValue xCenterY,
|
||||
long lArea,
|
||||
long lObject)
|
||||
{
|
||||
M_TdeAlloc( (*h_stSuperObject), TDE_tdsSuperObject *, (sizeof(TDE_tdsSuperObject)));
|
||||
if ((*h_stSuperObject) == NULL)
|
||||
return;
|
||||
(*h_stSuperObject)->sPriority = sPriority;
|
||||
(*h_stSuperObject)->p_stChild = p_stChild;
|
||||
(*h_stSuperObject)->p_stLeftBrother = p_stLeftBrother;
|
||||
(*h_stSuperObject)->p_stRightBrother = p_stRightBrother;
|
||||
(*h_stSuperObject)->p_stFather = p_stFather;
|
||||
(*h_stSuperObject)->eType = eType;
|
||||
(*h_stSuperObject)->stMatrix.xAngle = xAngle;
|
||||
(*h_stSuperObject)->stMatrix.stScale.xX = xZX;
|
||||
(*h_stSuperObject)->stMatrix.stScale.xY = xZY;
|
||||
(*h_stSuperObject)->p_stSOClipRect = NULL;
|
||||
(*h_stSuperObject)->stMatrix.stTranslateVertex.xX = xCenterX;
|
||||
(*h_stSuperObject)->stMatrix.stTranslateVertex.xY = xCenterY;
|
||||
(*h_stSuperObject)->lArea = lArea;
|
||||
(*h_stSuperObject)->lObject = lObject;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitSuperObject
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a TDE_tdsSuperObject structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitSuperObjectWithSprite(TDE_tdsSuperObject **h_stSuperObject,
|
||||
TDE_tdsSprite *p_stSprite,
|
||||
short sPriority,
|
||||
TDE_tdsSuperObject *p_stChild,
|
||||
TDE_tdsSuperObject *p_stLeftBrother,
|
||||
TDE_tdsSuperObject *p_stRightBrother,
|
||||
TDE_tdsSuperObject *p_stFather,
|
||||
TDE_tdxAngle xAngle,
|
||||
TDE_tdxValue xZX,
|
||||
TDE_tdxValue xZY,
|
||||
TDE_tdxValue xCenterX,
|
||||
TDE_tdxValue xCenterY,
|
||||
long lArea,
|
||||
long lObject)
|
||||
{
|
||||
M_TdeAlloc( (*h_stSuperObject), TDE_tdsSuperObject *, (sizeof(TDE_tdsSuperObject)));
|
||||
if ((*h_stSuperObject) == NULL)
|
||||
return;
|
||||
(*h_stSuperObject)->p_stSprite = p_stSprite;
|
||||
(*h_stSuperObject)->sPriority = sPriority;
|
||||
(*h_stSuperObject)->p_stChild = p_stChild;
|
||||
(*h_stSuperObject)->p_stLeftBrother = p_stLeftBrother;
|
||||
(*h_stSuperObject)->p_stRightBrother = p_stRightBrother;
|
||||
(*h_stSuperObject)->p_stFather = p_stFather;
|
||||
(*h_stSuperObject)->eType = TDE_eOT_SPRITE;
|
||||
(*h_stSuperObject)->stMatrix.xAngle = xAngle;
|
||||
(*h_stSuperObject)->stMatrix.stScale.xX = xZX;
|
||||
(*h_stSuperObject)->stMatrix.stScale.xY = xZY;
|
||||
(*h_stSuperObject)->p_stSOClipRect = NULL;
|
||||
(*h_stSuperObject)->stMatrix.stTranslateVertex.xX = xCenterX;
|
||||
(*h_stSuperObject)->stMatrix.stTranslateVertex.xY = xCenterY;
|
||||
(*h_stSuperObject)->lArea = lArea;
|
||||
(*h_stSuperObject)->lObject = lObject;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitLine
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a tdsLine structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitLine(TDE_tdsSuperObject *p_SuperObject,
|
||||
TDE_tdxValue xLength,
|
||||
long lColor)
|
||||
{
|
||||
M_TdeAlloc( p_SuperObject->p_stLine, TDE_tdsLine *, (sizeof(TDE_tdsLine)) );
|
||||
if (p_SuperObject->p_stLine == NULL)
|
||||
{
|
||||
p_SuperObject->eType = TDE_eOT_EMPTY;
|
||||
return;
|
||||
}
|
||||
p_SuperObject->eType = TDE_eOT_LINE;
|
||||
p_SuperObject->p_stLine->xLength = xLength;
|
||||
p_SuperObject->p_stLine->lColor = lColor;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitSprite
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a tdsSprite structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitSprite(TDE_tdsSuperObject *p_SuperObject,
|
||||
TDE_tdxValue xWidth,
|
||||
TDE_tdxValue xHeight,
|
||||
TDE_tdxValue xXs,
|
||||
TDE_tdxValue xYs,
|
||||
TDE_tdxPixel *v_pData,
|
||||
CHAR cFlip,
|
||||
CHAR c_NZ,
|
||||
CHAR cSemiTransparent,
|
||||
TDE_tdsPictureAttributes *p_stPicture)
|
||||
{
|
||||
M_TdeAlloc( p_SuperObject->p_stSprite, TDE_tdsSprite *, (sizeof(TDE_tdsSprite)) );
|
||||
if (p_SuperObject->p_stSprite == NULL)
|
||||
{
|
||||
p_SuperObject->eType = TDE_eOT_EMPTY;
|
||||
return;
|
||||
}
|
||||
p_SuperObject->p_stSprite->stDim.xX = xWidth;
|
||||
p_SuperObject->p_stSprite->stDim.xY = xHeight;
|
||||
p_SuperObject->p_stSprite->stSourceOrigin.xX = xXs;
|
||||
p_SuperObject->p_stSprite->stSourceOrigin.xY = xYs;
|
||||
p_SuperObject->p_stSprite->v_pData = v_pData;
|
||||
p_SuperObject->p_stSprite->cFlip = cFlip;
|
||||
p_SuperObject->p_stSprite->c_NZ = c_NZ;
|
||||
p_SuperObject->p_stSprite->cSemiTransparent = cSemiTransparent;
|
||||
p_SuperObject->p_stSprite->stPicture = *p_stPicture;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitMemSprite
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a tdsSprite structure for memory sprite
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitMemSprite(TDE_tdsSuperObject *p_SuperObject,
|
||||
TDE_tdxPixel *v_pData,
|
||||
CHAR c_NZ)
|
||||
{
|
||||
M_TdeAlloc( p_SuperObject->p_stSprite, TDE_tdsSprite *, (sizeof(TDE_tdsSprite)) );
|
||||
if (p_SuperObject->p_stSprite == NULL)
|
||||
{
|
||||
p_SuperObject->eType = TDE_eOT_EMPTY;
|
||||
return;
|
||||
}
|
||||
p_SuperObject->eType = TDE_eOT_SPRITE;
|
||||
p_SuperObject->p_stSprite->v_pData = v_pData;
|
||||
p_SuperObject->p_stSprite->c_NZ = c_NZ;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitMemSpriteWithoutSO
|
||||
VERSION : 2.0 / Yan
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a tdsSprite structure for memory sprite non attached
|
||||
to a super object
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitMemSpriteWithoutSO(TDE_tdsSprite **p_stSprite,
|
||||
TDE_tdxPixel *v_pData,
|
||||
CHAR c_NZ)
|
||||
{
|
||||
M_TdeAlloc( *p_stSprite, TDE_tdsSprite *, (sizeof(TDE_tdsSprite)) );
|
||||
if ((*p_stSprite) == NULL)
|
||||
return;
|
||||
(*p_stSprite)->v_pData = v_pData;
|
||||
(*p_stSprite)->c_NZ = c_NZ;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitTextBox
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Fills a tdsTextBox structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitTextBox (TDE_tdsSuperObject *p_SuperObject,
|
||||
TDE_tdeFontType eFontType,
|
||||
void *p_stFont,
|
||||
unsigned long ulStyle)
|
||||
{
|
||||
// Allocate memory for text box
|
||||
M_TdeAlloc( p_SuperObject->p_stTextBox, TDE_tdsTextBox *, (sizeof(TDE_tdsTextBox)) );
|
||||
if (p_SuperObject->p_stTextBox == NULL)
|
||||
return;
|
||||
// Allocate memory for format rectangle
|
||||
M_TdeAlloc(p_SuperObject->p_stTextBox->p_stFormatRect, TDE_tdsRect*, sizeof(TDE_tdsLRect));
|
||||
if (p_SuperObject->p_stTextBox->p_stFormatRect == NULL)
|
||||
{
|
||||
M_TdeFree (p_SuperObject->p_stTextBox);
|
||||
p_SuperObject->p_stTextBox = NULL;
|
||||
p_SuperObject->eType = TDE_eOT_EMPTY;
|
||||
return;
|
||||
}
|
||||
// Allocate memory for clipping
|
||||
M_TdeAlloc(p_SuperObject->p_stTextBox->p_stClipRect, TDE_tdsRect*, sizeof(TDE_tdsLRect));
|
||||
if (p_SuperObject->p_stTextBox->p_stClipRect == NULL)
|
||||
{
|
||||
M_TdeFree (p_SuperObject->p_stTextBox->p_stFormatRect);
|
||||
M_TdeFree (p_SuperObject->p_stTextBox);
|
||||
p_SuperObject->p_stTextBox = NULL;
|
||||
p_SuperObject->eType = TDE_eOT_EMPTY;
|
||||
return;
|
||||
}
|
||||
// Set font type and pointer to font
|
||||
p_SuperObject->p_stTextBox->eFontType = eFontType;
|
||||
switch (eFontType)
|
||||
{
|
||||
case TDE_eFT_BITMAP:
|
||||
p_SuperObject->p_stTextBox->p_stBFont = (TDE_tdsBitmapFont*)p_stFont;
|
||||
break;
|
||||
case TDE_eFT_TRUETYPE:
|
||||
p_SuperObject->p_stTextBox->p_stTFont = (TDE_tdsTrueTypeFont*)p_stFont;
|
||||
break;
|
||||
}
|
||||
// Set style
|
||||
p_SuperObject->p_stTextBox->ulStyle = ulStyle;
|
||||
// Set default values
|
||||
p_SuperObject->p_stTextBox->eCursorType = TDE_eCT_NOCURSOR;
|
||||
p_SuperObject->p_stTextBox->lCursorPosition = 0;
|
||||
p_SuperObject->p_stTextBox->p_cText = NULL;
|
||||
p_SuperObject->p_stTextBox->cColorMode = 0;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vCreateBitmapFont
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Allocation of a bitmap font structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vCreateBitmapFont(TDE_tdsBitmapFont **BFont)
|
||||
{
|
||||
long i;
|
||||
|
||||
M_TdeAlloc( *BFont, TDE_tdsBitmapFont *, (sizeof(TDE_tdsBitmapFont)) );
|
||||
if ((*BFont) == NULL)
|
||||
return;
|
||||
// initialize every characters to NULL
|
||||
for ( i=0; i<TDE_kNBLETTERS; i++ )
|
||||
{
|
||||
(*BFont)->p_stMBLetter[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vCreateTrueTypeFont
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Allocation of a true type font structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vCreateTrueTypeFont(TDE_tdsTrueTypeFont **TFont)
|
||||
{
|
||||
M_TdeAlloc( *TFont, TDE_tdsTrueTypeFont *, (sizeof(TDE_tdsTrueTypeFont)) );
|
||||
if ((*TFont) == NULL)
|
||||
return;
|
||||
(*TFont)->hFont = NULL;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vInitTransparencyTable()
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Init tables for semi-transparency
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vInitTransparencyTable()
|
||||
{
|
||||
char i, j;
|
||||
|
||||
for (i=0; i<64; i++)
|
||||
{
|
||||
for (j=0; j<64; j++)
|
||||
{
|
||||
a_cTransparencyTable6[i][j] = (unsigned char) ((i*j)/63);
|
||||
}
|
||||
for (j=0; j<32; j++)
|
||||
{
|
||||
a_cTransparencyTable5[i][j] = (unsigned char) ((i*j)/63);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
TDE_INIT.C
|
||||
Second part : FUNCTIONS USED TO CHANGE A STRUCTURE FIELD
|
||||
|
||||
- TDE_vSetSourcePointer
|
||||
- TDE_vSetSuperObjectDescendantsSourcePointer
|
||||
- TDE_vSetSourcePitch
|
||||
- TDE_vSetSuperObjectDescendantsSourcePitch
|
||||
- TDE_vChangeTextInTheBox
|
||||
- TDE_vChangeCursorType
|
||||
- TDE_vChangeCursorPosition
|
||||
- TDE_vChangeFormatRectangle
|
||||
- TDE_vChangeClipRectangle
|
||||
- TDE_vMoveFormatRectangle
|
||||
- TDE_vMoveClipRectangle
|
||||
- TDE_vChangeSuperObjetCoordinates
|
||||
- TDE_vChangeSuperObjetScale
|
||||
- TDE_vChangeSuperObjetAngle
|
||||
- TDE_vChangeSuperObjectFlip
|
||||
- TDE_vChangeSuperObjectAlpha
|
||||
- TDE_vChangeSuperObjectDescendantsAlpha
|
||||
- TDE_vChangeSuperObjectSemiTransparency
|
||||
- TDE_vChangeSuperObjectDescendantsSemiTransparency
|
||||
- TDE_vChangeSourceCoordinates
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vSetSourcePointer
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the pointer of a picture definition
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vSetSourcePointer(TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdLP_SOURCE lp_Data)
|
||||
{
|
||||
p_stSuperObject->p_stSprite->stPicture.lp_Data = lp_Data;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vSetSuperObjectDescendantsSourcePointer
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Set the source pointer (has to be called when the source is locked)
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vSetSuperObjectDescendantsSourcePointer(TDE_tdsSuperObject *p_stSuperObject, TDE_tdLP_SOURCE lp_Data)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
TDE_vSetSourcePointer(p_stSuperObject, lp_Data);
|
||||
for ( p_stSuperObjectTemp = p_stSuperObject->p_stChild; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stRightBrother)
|
||||
{
|
||||
TDE_vSetSuperObjectDescendantsSourcePointer(p_stSuperObjectTemp, lp_Data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vSetSourcePitch
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the pitch of a picture definition
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vSetSourcePitch(TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdxValue xSrcPitch)
|
||||
{
|
||||
p_stSuperObject->p_stSprite->stPicture.xSrcPitch = xSrcPitch;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vSetSuperObjectDescendantsSourcePitch
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Set the source pitch (has to be called when the source is locked)
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vSetSuperObjectDescendantsSourcePitch(TDE_tdsSuperObject *p_stSuperObject, TDE_tdxValue xSrcPitch)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
TDE_vSetSourcePitch(p_stSuperObject, xSrcPitch);
|
||||
for ( p_stSuperObjectTemp = p_stSuperObject->p_stChild; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stRightBrother)
|
||||
{
|
||||
TDE_vSetSuperObjectDescendantsSourcePitch(p_stSuperObjectTemp, xSrcPitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeFormatRectangle
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the format rectangle of a text box
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeFormatRectangle(TDE_tdsTextBox *Box, TDE_tdxValue xCornerX, TDE_tdxValue xCornerY, TDE_tdxValue xWidth, TDE_tdxValue xHeight)
|
||||
{
|
||||
Box->p_stFormatRect->tdsSommet[0].xX = xCornerX;
|
||||
Box->p_stFormatRect->tdsSommet[0].xY = xCornerY;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[1].xX = xCornerX + xWidth-1;
|
||||
Box->p_stFormatRect->tdsSommet[1].xY = xCornerY;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[2].xX = xCornerX + xWidth-1;
|
||||
Box->p_stFormatRect->tdsSommet[2].xY = xCornerY + xHeight-1;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[3].xX = xCornerX;
|
||||
Box->p_stFormatRect->tdsSommet[3].xY = xCornerY + xHeight-1;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeClipRectangle
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the clipping rectangle of a text box
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeClipRectangle(TDE_tdsTextBox *Box, TDE_tdxValue xCornerX, TDE_tdxValue xCornerY, TDE_tdxValue xWidth, TDE_tdxValue xHeight)
|
||||
{
|
||||
Box->p_stClipRect->tdsSommet[0].xX = xCornerX;
|
||||
Box->p_stClipRect->tdsSommet[0].xY = xCornerY;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[1].xX = xCornerX + xWidth-1;
|
||||
Box->p_stClipRect->tdsSommet[1].xY = xCornerY;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[2].xX = xCornerX + xWidth-1;
|
||||
Box->p_stClipRect->tdsSommet[2].xY = xCornerY + xHeight-1;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[3].xX = xCornerX;
|
||||
Box->p_stClipRect->tdsSommet[3].xY = xCornerY + xHeight-1;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vMoveFormatRectangle
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Translate the format rectangle of a text box
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vMoveFormatRectangle(TDE_tdsTextBox *Box, TDE_tdxValue xDx, TDE_tdxValue xDy)
|
||||
{
|
||||
Box->p_stFormatRect->tdsSommet[0].xX += xDx;
|
||||
Box->p_stFormatRect->tdsSommet[0].xY += xDy;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[1].xX += xDx;
|
||||
Box->p_stFormatRect->tdsSommet[1].xY += xDy;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[2].xX += xDx;
|
||||
Box->p_stFormatRect->tdsSommet[2].xY += xDy;
|
||||
|
||||
Box->p_stFormatRect->tdsSommet[3].xX += xDx;
|
||||
Box->p_stFormatRect->tdsSommet[3].xY += xDy;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vMoveClipRectangle
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Translate the clipping rectangle of a text box
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vMoveClipRectangle(TDE_tdsTextBox *Box, TDE_tdxValue xDx, TDE_tdxValue xDy)
|
||||
{
|
||||
Box->p_stClipRect->tdsSommet[0].xX += xDx;
|
||||
Box->p_stClipRect->tdsSommet[0].xY += xDy;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[1].xX += xDx;
|
||||
Box->p_stClipRect->tdsSommet[1].xY += xDy;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[2].xX += xDx;
|
||||
Box->p_stClipRect->tdsSommet[2].xY += xDy;
|
||||
|
||||
Box->p_stClipRect->tdsSommet[3].xX += xDx;
|
||||
Box->p_stClipRect->tdsSommet[3].xY += xDy;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeTextInTheBox
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the pointer to the text in a TextBox
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeTextInTheBox (TDE_tdsSuperObject *p_SuperObject,
|
||||
char *p_cText)
|
||||
{
|
||||
p_SuperObject->p_stTextBox->p_cText = p_cText;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeCursorType
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the cursor type in a TextBox
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeCursorType (TDE_tdsSuperObject *p_SuperObject,
|
||||
TDE_tdeCursorType eType)
|
||||
{
|
||||
p_SuperObject->p_stTextBox->eCursorType = eType;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeCursorPosition
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the cursor position in a TextBox
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeCursorPosition (TDE_tdsSuperObject *p_SuperObject,
|
||||
long lPosition)
|
||||
{
|
||||
p_SuperObject->p_stTextBox->lCursorPosition = lPosition;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeColorModeInTextBox
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Change the color mode in a TextBox
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeColorModeInTextBox (TDE_tdsSuperObject *p_SuperObject,
|
||||
char cColorMode)
|
||||
{
|
||||
p_SuperObject->p_stTextBox->cColorMode = cColorMode;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjetCoordinates
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the super object center coordinates
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vChangeSuperObjetCoordinates(TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdxValue xX,
|
||||
TDE_tdxValue xY)
|
||||
{
|
||||
p_stSuperObject->stMatrix.stTranslateVertex.xX = xX;
|
||||
p_stSuperObject->stMatrix.stTranslateVertex.xY = xY;
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjetScale
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the super object X and Y scale factors
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjetScale(TDE_tdsSuperObject *p_stSuperObject,
|
||||
TDE_tdxValue xZX,
|
||||
TDE_tdxValue xZY)
|
||||
{
|
||||
p_stSuperObject->stMatrix.stScale.xX = xZX;
|
||||
p_stSuperObject->stMatrix.stScale.xY = xZY;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjetAngle
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the super object angle
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjetAngle(TDE_tdsSuperObject *p_stSuperObjet,
|
||||
TDE_tdxAngle xAngle)
|
||||
{
|
||||
p_stSuperObjet->stMatrix.xAngle = xAngle;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjectFlip
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the super object flip parameter
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjectFlip(TDE_tdsSuperObject *p_stSuperObjet,
|
||||
char cFlip)
|
||||
{
|
||||
p_stSuperObjet->p_stSprite->cFlip = cFlip&3;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjectAlpha
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Modify alpha channel for a superobject
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjectAlpha(TDE_tdsSuperObject *p_stSuperObjet,
|
||||
TDE_tdxValue xAlpha)
|
||||
{
|
||||
p_stSuperObjet->p_stSprite->alpha = xAlpha;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjectSemiTransparency
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Enables or disables semi-transparency property
|
||||
1 -> enable
|
||||
0 -> disable
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjectSemiTransparency(TDE_tdsSuperObject *p_stSuperObjet,
|
||||
char cSemiTransparent)
|
||||
{
|
||||
p_stSuperObjet->p_stSprite->cSemiTransparent = cSemiTransparent;
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjectDescendantsSemiTransparency
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Enables or disables semi-transparency property for a SuperObject and
|
||||
his descendants
|
||||
1 -> enable
|
||||
0 -> disable
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjectDescendantsSemiTransparency(TDE_tdsSuperObject *p_stSuperObject, char cSemiTransparent)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
TDE_vChangeSuperObjectSemiTransparency(p_stSuperObject, cSemiTransparent);
|
||||
for ( p_stSuperObjectTemp = p_stSuperObject->p_stChild; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stRightBrother)
|
||||
{
|
||||
TDE_vChangeSuperObjectDescendantsSemiTransparency(p_stSuperObjectTemp, cSemiTransparent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSuperObjectDescendantsAlpha
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Modify alpha channel for a superobject and its descendants
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSuperObjectDescendantsAlpha(TDE_tdsSuperObject *p_stSuperObject, TDE_tdxValue xAlpha)
|
||||
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
TDE_vChangeSuperObjectAlpha(p_stSuperObject, xAlpha);
|
||||
for ( p_stSuperObjectTemp = p_stSuperObject->p_stChild; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stRightBrother)
|
||||
{
|
||||
TDE_vChangeSuperObjectDescendantsAlpha(p_stSuperObjectTemp, xAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vChangeSourceCoordinates
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Changes the source picture coordinates of a sprite
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vChangeSourceCoordinates(TDE_tdsSprite *p_stSprite,
|
||||
TDE_tdxValue xXs,
|
||||
TDE_tdxValue xYs)
|
||||
{
|
||||
p_stSprite->stSourceOrigin.xX = xXs;
|
||||
p_stSprite->stSourceOrigin.xY = xYs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
||||
TDE_INIT.C
|
||||
Third part : Get Functions
|
||||
|
||||
- TDE_eGetCursorType
|
||||
- TDE_lGetCursorPosition
|
||||
*************************************************************************/
|
||||
|
||||
TDE_tdeCursorType TDE_eGetCursorType ( TDE_tdsSuperObject *p_SuperObject )
|
||||
{
|
||||
return p_SuperObject->p_stTextBox->eCursorType;
|
||||
}
|
||||
|
||||
long TDE_lGetCursorPosition ( TDE_tdsSuperObject *p_SuperObject )
|
||||
{
|
||||
return p_SuperObject->p_stTextBox->lCursorPosition;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
TDE_INIT.C
|
||||
fourth part : LIBERATION FUNCTIONS
|
||||
|
||||
- TDE_vReleaseMenuBitmapFont
|
||||
- TDE_vReleaseTrueTypeFont
|
||||
- TDE_vReleaseMemSprite
|
||||
- TDE_vDestroyPictureAttributes
|
||||
- TDE_vDestroyTextBox
|
||||
- TDE_vDestroySuperObject
|
||||
- TDE_vDestroySuperObjectDescendants
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vReleaseBitmapFont
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Destroy a bitmap font structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vReleaseBitmapFont(TDE_tdsBitmapFont *BFont)
|
||||
{
|
||||
short i;
|
||||
|
||||
if (BFont == NULL)
|
||||
return;
|
||||
for ( i=0; i<TDE_kNBLETTERS; i++ )
|
||||
{
|
||||
if (BFont->p_stMBLetter[i] != NULL)
|
||||
{
|
||||
if (BFont->p_stMBLetter[i]->stBLetter.p_stSprite != NULL)
|
||||
{
|
||||
if (BFont->p_stMBLetter[i]->stBLetter.p_stSprite->v_pData != NULL)
|
||||
{
|
||||
// sprite data
|
||||
M_TdeFree( BFont->p_stMBLetter[i]->stBLetter.p_stSprite->v_pData );
|
||||
}
|
||||
// sprite
|
||||
M_TdeFree( BFont->p_stMBLetter[i]->stBLetter.p_stSprite );
|
||||
}
|
||||
// Letter
|
||||
M_TdeFree( BFont->p_stMBLetter[i]);
|
||||
}
|
||||
}
|
||||
M_TdeFree(BFont);
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vReleaseTrueTypeFont
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Destroy a true type font structure
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vReleaseTrueTypeFont(TDE_tdsTrueTypeFont *TFont)
|
||||
{
|
||||
if (TFont == NULL)
|
||||
return;
|
||||
if (TFont->hFont != NULL)
|
||||
DeleteObject ((HGDIOBJ)TFont->hFont);
|
||||
M_TdeFree(TFont);
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vReleaseMemSprite
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Frees a memory sprite
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vReleaseMemSprite(TDE_tdsSprite *p_stSprite)
|
||||
{
|
||||
if (p_stSprite)
|
||||
{
|
||||
if (p_stSprite->v_pData)
|
||||
M_TdeFree(p_stSprite->v_pData);
|
||||
M_TdeFree(p_stSprite);
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDestroyPictureAttributes
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Free a TDE_tdsPictureAttributes object
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vDestroyPictureAttributes(TDE_tdsPictureAttributes **h_stPicture)
|
||||
{
|
||||
M_TdeFree(*h_stPicture);
|
||||
*h_stPicture = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDestroyTextBox
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Free a tdsTextBox object
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDestroyTextBox(TDE_tdsTextBox **h_stTextBox)
|
||||
{
|
||||
if (*h_stTextBox)
|
||||
{
|
||||
if ((*h_stTextBox)->p_stFormatRect)
|
||||
M_TdeFree ((*h_stTextBox)->p_stFormatRect);
|
||||
if ((*h_stTextBox)->p_stClipRect)
|
||||
M_TdeFree ((*h_stTextBox)->p_stClipRect);
|
||||
M_TdeFree(*h_stTextBox);
|
||||
*h_stTextBox = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDestroySuperObject
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Free a tdsSuperObject object
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vDestroySuperObject(TDE_tdsSuperObject **h_stSuperObject)
|
||||
{
|
||||
if (*h_stSuperObject)
|
||||
{
|
||||
M_TdeFree(*h_stSuperObject);
|
||||
*h_stSuperObject = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vDestroySuperObjectDescendants
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Free a tdsSuperObject object
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
|
||||
void TDE_vDestroySuperObjectDescendants(TDE_tdsSuperObject **h_stSuperObject)
|
||||
{
|
||||
char NotFinished = 1;
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp, *p_stSuperObject = *h_stSuperObject;
|
||||
|
||||
while (NotFinished)
|
||||
{
|
||||
if (p_stSuperObject->p_stChild) p_stSuperObject = p_stSuperObject->p_stChild;
|
||||
else
|
||||
{
|
||||
if (p_stSuperObject->p_stRightBrother)
|
||||
{
|
||||
p_stSuperObjectTemp = p_stSuperObject;
|
||||
p_stSuperObject = p_stSuperObject->p_stRightBrother;
|
||||
if (p_stSuperObjectTemp->p_stFather)
|
||||
{
|
||||
p_stSuperObject->p_stFather = p_stSuperObjectTemp->p_stFather;
|
||||
p_stSuperObject->p_stFather->p_stChild = p_stSuperObject;
|
||||
}
|
||||
//free(p_stSuperObjectTemp);
|
||||
M_TdeFree(p_stSuperObjectTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p_stSuperObject->p_stFather)
|
||||
{
|
||||
p_stSuperObject = p_stSuperObject->p_stFather;
|
||||
//free(p_stSuperObject->p_stChild);
|
||||
M_TdeFree(p_stSuperObject->p_stChild);
|
||||
p_stSuperObject->p_stChild = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//free(p_stSuperObject);
|
||||
M_TdeFree(p_stSuperObject);
|
||||
NotFinished = 0;
|
||||
(*h_stSuperObject) = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
187
Rayman_X/cpa/tempgrp/TDE/tde_matrix.c
Normal file
187
Rayman_X/cpa/tempgrp/TDE/tde_matrix.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*******************************************************************************************
|
||||
|
||||
File : Matrix.cpp
|
||||
Date : 26 august 96
|
||||
|
||||
********************************************************************************************/
|
||||
|
||||
#include "TDE.h"
|
||||
|
||||
void TDE_vGetTranslateVertexMatrix(TDE_tdsSuperObjectMatrix *p_stMatrix, TDE_tdsVertex *p_stTranslate)
|
||||
{
|
||||
*p_stTranslate = p_stMatrix->stTranslateVertex;
|
||||
}
|
||||
|
||||
|
||||
void TDE_vGetAngleMatrix(TDE_tdsSuperObjectMatrix *p_stMatrix, TDE_tdxAngle *p_xAngle)
|
||||
{
|
||||
*p_xAngle = p_stMatrix->xAngle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TDE_vCreateRotationMatrix(TDE_tdsMatrix *p_stMatrix, TDE_tdxAngle xAngle)
|
||||
{
|
||||
TDE_tdxValue xCosi, xSinu;
|
||||
|
||||
xCosi = TDE_M_Cos(xAngle);
|
||||
xSinu = TDE_M_Sin(xAngle);
|
||||
|
||||
p_stMatrix->a4_xM[0][0] = xCosi;
|
||||
p_stMatrix->a4_xM[0][1] = -xSinu;
|
||||
p_stMatrix->a4_xM[1][0] = xSinu;
|
||||
p_stMatrix->a4_xM[1][1] = xCosi;
|
||||
}
|
||||
|
||||
void TDE_vCreateScaleMatrix(TDE_tdsMatrix *p_stMatrix, TDE_tdxValue xZX, TDE_tdxValue xZY)
|
||||
{
|
||||
p_stMatrix->a4_xM[0][0] = xZX;
|
||||
p_stMatrix->a4_xM[0][1] = 0;
|
||||
p_stMatrix->a4_xM[1][0] = 0;
|
||||
p_stMatrix->a4_xM[1][1] = xZY;
|
||||
}
|
||||
|
||||
|
||||
void TDE_vMulMatrixByMatrix(TDE_tdsMatrix *p_stMat1, TDE_tdsMatrix *p_stMat2, TDE_tdsMatrix *p_stResult)
|
||||
{
|
||||
TDE_tdsMatrix stMtemp;
|
||||
|
||||
stMtemp.a4_xM[0][0] = TDE_M_Mul(p_stMat1->a4_xM[0][0], p_stMat2->a4_xM[0][0])+
|
||||
TDE_M_Mul(p_stMat1->a4_xM[0][1], p_stMat2->a4_xM[1][0]);
|
||||
|
||||
stMtemp.a4_xM[0][1] = TDE_M_Mul(p_stMat1->a4_xM[0][0], p_stMat2->a4_xM[0][1])+
|
||||
TDE_M_Mul(p_stMat1->a4_xM[0][1], p_stMat2->a4_xM[1][1]);
|
||||
|
||||
stMtemp.a4_xM[1][0] = TDE_M_Mul(p_stMat1->a4_xM[1][0], p_stMat2->a4_xM[0][0])+
|
||||
TDE_M_Mul(p_stMat1->a4_xM[1][1], p_stMat2->a4_xM[1][0]);
|
||||
|
||||
stMtemp.a4_xM[1][1] = TDE_M_Mul(p_stMat1->a4_xM[1][0], p_stMat2->a4_xM[0][1])+
|
||||
TDE_M_Mul(p_stMat1->a4_xM[1][1], p_stMat2->a4_xM[1][1]);
|
||||
|
||||
*p_stResult = stMtemp;
|
||||
}
|
||||
|
||||
void TDE_vMulMatrixByVertex(TDE_tdsMatrix *p_stMat, TDE_tdsVertex *p_stV, TDE_tdsVertex *p_stR)
|
||||
{
|
||||
TDE_tdsVertex stVtemp;
|
||||
|
||||
stVtemp.xX = TDE_M_Mul(p_stMat->a4_xM[0][0], p_stV->xX) +
|
||||
TDE_M_Mul(p_stMat->a4_xM[0][1], p_stV->xY);
|
||||
|
||||
stVtemp.xY = TDE_M_Mul(p_stMat->a4_xM[1][0], p_stV->xX) +
|
||||
TDE_M_Mul(p_stMat->a4_xM[1][1], p_stV->xY);
|
||||
|
||||
*p_stR = stVtemp;
|
||||
}
|
||||
|
||||
void TDE_vAddVertexToVertex(TDE_tdsVertex *p_stV1, TDE_tdsVertex *p_stV2, TDE_tdsVertex *p_stResult)
|
||||
{
|
||||
p_stResult->xX = p_stV1->xX + p_stV2->xX;
|
||||
p_stResult->xY = p_stV1->xY + p_stV2->xY;
|
||||
}
|
||||
|
||||
void TDE_vSubVertexToVertex(TDE_tdsVertex *p_stV1, TDE_tdsVertex *p_stV2, TDE_tdsVertex *p_stResult)
|
||||
{
|
||||
p_stResult->xX = p_stV1->xX - p_stV2->xX;
|
||||
p_stResult->xY = p_stV1->xY - p_stV2->xY;
|
||||
}
|
||||
|
||||
TDE_tdxValue TDE_xNormeVertex(TDE_tdsVertex *p_stV)
|
||||
{
|
||||
return TDE_M_Sqrt(TDE_M_Add(TDE_M_Sq(p_stV->xX),
|
||||
TDE_M_Sq(p_stV->xY)));
|
||||
}
|
||||
|
||||
void TDE_vNormerVertex(TDE_tdsVertex *p_stV, TDE_tdsVertex *p_stResult)
|
||||
{
|
||||
TDE_tdxValue xNorme;
|
||||
|
||||
xNorme = TDE_xNormeVertex(p_stV);
|
||||
|
||||
p_stResult->xX = TDE_M_Div(p_stV->xX, xNorme);
|
||||
p_stResult->xY = TDE_M_Div(p_stV->xY, xNorme);
|
||||
}
|
||||
|
||||
void TDE_vMulVertexToValue(TDE_tdsVertex *p_stV, TDE_tdxValue xValue, TDE_tdsVertex *p_stResult)
|
||||
{
|
||||
p_stResult->xX = TDE_M_Mul( p_stV->xX, xValue);
|
||||
p_stResult->xY = TDE_M_Mul( p_stV->xY, xValue);
|
||||
}
|
||||
|
||||
|
||||
void TDE_vCreateSuperObjectMatrix(TDE_tdsSuperObjectMatrix *p_stMatrix)
|
||||
{
|
||||
TDE_tdsMatrix stR;
|
||||
|
||||
TDE_vCreateRotationMatrix(&stR, p_stMatrix->xAngle);
|
||||
TDE_vCreateScaleMatrix(&(p_stMatrix->a4_xS), p_stMatrix->stScale.xX, p_stMatrix->stScale.xY);
|
||||
TDE_vMulMatrixByMatrix(&stR, &(p_stMatrix->a4_xS), &(p_stMatrix->a4_xRxS));
|
||||
}
|
||||
|
||||
|
||||
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
|
||||
NAME : TDE_vCreateSuperObjectDescendancyMatrices
|
||||
VERSION : 2.0 / Val<61>rie
|
||||
1.0 / Franck
|
||||
|
||||
AIM : Create a SuperObject and his descendancy matrices
|
||||
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
|
||||
void TDE_vCreateSuperObjectDescendancyMatrices(TDE_tdsSuperObject *p_stSuperObject)
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSuperObjectTemp;
|
||||
|
||||
TDE_vCreateSuperObjectMatrix(&(p_stSuperObject->stMatrix));
|
||||
if ( p_stSuperObject->p_stChild != NULL )
|
||||
{
|
||||
for ( p_stSuperObjectTemp = p_stSuperObject->p_stChild; p_stSuperObjectTemp != NULL; p_stSuperObjectTemp = p_stSuperObjectTemp->p_stRightBrother)
|
||||
{
|
||||
TDE_vCreateSuperObjectDescendancyMatrices(p_stSuperObjectTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TDE_vMulSOMatrixBySOMatrix(TDE_tdsSuperObjectMatrix *p_stMat1, TDE_tdsSuperObjectMatrix *p_stMat2, TDE_tdsSuperObjectMatrix *p_stResult)
|
||||
{
|
||||
|
||||
TDE_vMulMatrixByMatrix(&(p_stMat1->a4_xRxS), &(p_stMat2->a4_xRxS), &(p_stResult->a4_xRxS));
|
||||
TDE_vMulMatrixByVertex(&(p_stMat1->a4_xRxS), &(p_stMat2->stTranslateVertex), &(p_stResult->stTranslateVertex));
|
||||
TDE_vAddVertexToVertex(&(p_stResult->stTranslateVertex), &(p_stMat1->stTranslateVertex), &(p_stResult->stTranslateVertex));
|
||||
}
|
||||
|
||||
|
||||
void PushMatrix(TDE_tdsSuperObjectMatrix *p_stMat)
|
||||
{
|
||||
MS_Position++;
|
||||
if (MS_Position >= TDE_kSTACKDEPTH)
|
||||
{
|
||||
Erm_M_UpdateLastError (Tde,
|
||||
C_ucErmDefaultChannel,
|
||||
E_uwTdeWarningMatrixStackOverflow,
|
||||
C_lErmNoDebugData,
|
||||
C_ucErmOpenInfoWindow,
|
||||
C_ucAllowStopForDebug, NULL);
|
||||
MatrixStack[TDE_kSTACKDEPTH-1] = *p_stMat;
|
||||
TDE_vMulSOMatrixBySOMatrix(&MatrixStack[TDE_kSTACKDEPTH-2], &MatrixStack[TDE_kSTACKDEPTH-1], &MatrixStack[TDE_kSTACKDEPTH-1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
MatrixStack[MS_Position] = *p_stMat;
|
||||
if (MS_Position>0)
|
||||
{
|
||||
TDE_vMulSOMatrixBySOMatrix(&MatrixStack[MS_Position-1], &MatrixStack[MS_Position], &MatrixStack[MS_Position]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResetMatrixStack(TDE_tdsCamera *stCamera)
|
||||
{
|
||||
MS_Position=-1;
|
||||
PushMatrix(stCamera);
|
||||
}
|
||||
|
||||
void PopMatrix()
|
||||
{
|
||||
MS_Position--;
|
||||
}
|
||||
|
282
Rayman_X/cpa/tempgrp/TDE/tde_pick.c
Normal file
282
Rayman_X/cpa/tempgrp/TDE/tde_pick.c
Normal file
@@ -0,0 +1,282 @@
|
||||
/**************************************************************************************
|
||||
|
||||
File : PICKING.CPP
|
||||
Author : Marc Villemain
|
||||
Last update : 13 September 1996
|
||||
|
||||
***************************************************************************************/
|
||||
|
||||
|
||||
#include "tde.h"
|
||||
|
||||
// Precision de la souris en pixels
|
||||
#define C_PREC_SOURIS TDE_M_FloatToValue((float)3.0)
|
||||
|
||||
// Distance euclidienne entre deux points 2D
|
||||
#define M_DistancePointPoint(A,B) TDE_M_Sqrt(TDE_M_Add(TDE_M_Sq(TDE_M_Sub(A->xX,B->xX)), \
|
||||
TDE_M_Sq(TDE_M_Sub(A->xY,B->xY))))
|
||||
|
||||
|
||||
|
||||
static long lViewPortW, lViewPortH;
|
||||
static TDE_tdsSuperObjectMatrix stSprMatrix;
|
||||
|
||||
void fn_vChangeRepere ( TDE_tdsVertex *p_stP,
|
||||
TDE_tdsVertex *p_stA,
|
||||
TDE_tdsVertex *p_stB,
|
||||
TDE_tdsVertex *p_stC,
|
||||
TDE_tdsVertex *p_stR )
|
||||
{
|
||||
TDE_tdsVertex stAB, stAC, stAP;
|
||||
TDE_tdxValue denominateur;
|
||||
|
||||
// calcul des vecteurs de base du triangle
|
||||
TDE_vSubVertexToVertex( p_stB, p_stA, &stAB) ;
|
||||
TDE_vSubVertexToVertex( p_stC, p_stA, &stAC) ;
|
||||
TDE_vSubVertexToVertex( p_stP, p_stA, &stAP) ;
|
||||
|
||||
// coordonnee de p_stP dans le repere A,AB,AC
|
||||
denominateur = TDE_M_Sub(TDE_M_Mul(stAB.xX,stAC.xY),TDE_M_Mul(stAB.xY,stAC.xX));
|
||||
|
||||
p_stR->xX = TDE_M_Div(TDE_M_Sub(TDE_M_Mul(stAP.xX,stAC.xY),TDE_M_Mul(stAP.xY,stAC.xX)),
|
||||
denominateur);
|
||||
p_stR->xY = TDE_M_Div(TDE_M_Sub(TDE_M_Mul(stAB.xX,stAP.xY),TDE_M_Mul(stAB.xY,stAP.xX)),
|
||||
denominateur);
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bPickTriangle( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsVertex *p_stA,
|
||||
TDE_tdsVertex *p_stB,
|
||||
TDE_tdsVertex *p_stC )
|
||||
{
|
||||
TDE_tdsVertex stRet;
|
||||
|
||||
fn_vChangeRepere(p_stSouris, p_stA, p_stB, p_stC, &stRet);
|
||||
|
||||
/* on teste si le point est dans le triangle A,B,C */
|
||||
if ( ( stRet.xX >= TDE_M_FloatToValue( 0.0 ))
|
||||
&& ( stRet.xY >= TDE_M_FloatToValue( 0.0 ))
|
||||
&& ( TDE_M_Add( stRet.xX, stRet.xY ) <= TDE_M_FloatToValue( 1.0 )))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL GLI_bPickPoly4( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsVertex *p_stA,
|
||||
TDE_tdsVertex *p_stB,
|
||||
TDE_tdsVertex *p_stC,
|
||||
TDE_tdsVertex *p_stD )
|
||||
{
|
||||
BOOL ret1,ret2;
|
||||
|
||||
ret1 = GLI_bPickTriangle(p_stSouris,p_stA,p_stB,p_stC)
|
||||
|| GLI_bPickTriangle(p_stSouris,p_stA,p_stC,p_stD);
|
||||
|
||||
ret2 = GLI_bPickTriangle(p_stSouris,p_stD,p_stA,p_stB)
|
||||
|| GLI_bPickTriangle(p_stSouris,p_stD,p_stB,p_stC);
|
||||
|
||||
return ret1 && ret2;
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bPickPoint( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsVertex *p_stA )
|
||||
{
|
||||
return M_DistancePointPoint(p_stSouris, p_stA) <= C_PREC_SOURIS;
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bPickSegment( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsVertex *p_stP1,
|
||||
TDE_tdsVertex *p_stP2 )
|
||||
{
|
||||
TDE_tdsVertex stA,stB,stC,stD; // vecteurs du quadrilatere
|
||||
TDE_tdsVertex stDir,stNor; // vecteurs directeur et normal
|
||||
|
||||
// calcul des vecteurs directeur et normal
|
||||
TDE_vSubVertexToVertex( p_stP2, p_stP1, &stDir) ;
|
||||
stNor.xX = TDE_M_Neg(stDir.xY);
|
||||
stNor.xY = stDir.xX;
|
||||
|
||||
// on leur donne la longueur C_PREC_SOURIS
|
||||
TDE_vNormerVertex(&stDir, &stDir);
|
||||
TDE_vNormerVertex(&stNor, &stNor);
|
||||
TDE_vMulVertexToValue(&stDir, C_PREC_SOURIS, &stDir);
|
||||
TDE_vMulVertexToValue(&stNor, C_PREC_SOURIS, &stNor);
|
||||
|
||||
stA.xX = TDE_M_Sub( TDE_M_Add( p_stP1->xX, stNor.xX ), stDir.xX );
|
||||
stA.xY = TDE_M_Sub( TDE_M_Add( p_stP1->xY, stNor.xY ), stDir.xY );;
|
||||
|
||||
stB.xX = TDE_M_Sub( TDE_M_Sub( p_stP1->xX, stNor.xX ), stDir.xX );
|
||||
stB.xY = TDE_M_Sub( TDE_M_Sub( p_stP1->xY, stNor.xY ), stDir.xY );;
|
||||
|
||||
stC.xX = TDE_M_Add( TDE_M_Sub( p_stP2->xX, stNor.xX ), stDir.xX );
|
||||
stC.xY = TDE_M_Add( TDE_M_Sub( p_stP2->xY, stNor.xY ), stDir.xY );;
|
||||
|
||||
stD.xX = TDE_M_Add( TDE_M_Add( p_stP2->xX, stNor.xX ), stDir.xX );
|
||||
stD.xY = TDE_M_Add( TDE_M_Add( p_stP2->xY, stNor.xY ), stDir.xY );
|
||||
|
||||
return GLI_bPickPoly4(p_stSouris, &stA, &stB, &stC, &stD);
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bPickSprite( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsSprite *p_stSprite )
|
||||
{
|
||||
TDE_tdsRect stRect;
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterY;
|
||||
TDE_tdxValue xSpriteCornerX, xSpriteCornerY, xSpriteCenterX;
|
||||
|
||||
xScaledSpriteW = TDE_M_Mul(lViewPortW,p_stSprite->stDim.xX);
|
||||
xScaledSpriteH = TDE_M_Mul(lViewPortH,p_stSprite->stDim.xY);
|
||||
xSpriteCenterX = TDE_M_Mul(lViewPortW,stSprMatrix.stTranslateVertex.xX);
|
||||
xSpriteCenterY = TDE_M_Mul(lViewPortH,stSprMatrix.stTranslateVertex.xY);
|
||||
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW,2);
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH,2);
|
||||
|
||||
iTDE_vFillsRect(&stRect, xSpriteCornerX, xSpriteCornerY, xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
return GLI_bPickPoly4( p_stSouris,
|
||||
&stRect.tdsSommet[0],
|
||||
&stRect.tdsSommet[1],
|
||||
&stRect.tdsSommet[2],
|
||||
&stRect.tdsSommet[3] );
|
||||
}
|
||||
|
||||
BOOL GLI_bPickSpriteAbs( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsSprite *p_stSprite,
|
||||
TDE_tdxPixel *p_Color )
|
||||
{
|
||||
long decal;
|
||||
TDE_tdsRect stRect;
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xSpriteCenterY;
|
||||
TDE_tdxValue xSpriteCornerX, xSpriteCornerY, xSpriteCenterX;
|
||||
|
||||
xScaledSpriteW = p_stSprite->stDim.xX;
|
||||
xScaledSpriteH = p_stSprite->stDim.xY;
|
||||
xSpriteCenterX = stSprMatrix.stTranslateVertex.xX;
|
||||
xSpriteCenterY = stSprMatrix.stTranslateVertex.xY;
|
||||
|
||||
xSpriteCornerX = xSpriteCenterX - TDE_M_Div(xScaledSpriteW,2);
|
||||
xSpriteCornerY = xSpriteCenterY - TDE_M_Div(xScaledSpriteH,2);
|
||||
|
||||
iTDE_vFillsRect(&stRect, xSpriteCornerX, xSpriteCornerY, xScaledSpriteW, xScaledSpriteH);
|
||||
|
||||
decal = TDE_M_ValueToLong(p_stSprite->stDim.xX) * (TDE_M_ValueToLong(p_stSouris->xY)-TDE_M_ValueToLong(stRect.tdsSommet[0].xY)) + TDE_M_ValueToLong((p_stSouris->xX)-TDE_M_ValueToLong(stRect.tdsSommet[0].xX));
|
||||
if( (decal < 0) || (decal >= p_stSprite->stDim.xX*p_stSprite->stDim.xY) )
|
||||
{
|
||||
*p_Color = 0;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
*p_Color = p_stSprite->v_pData[decal];
|
||||
|
||||
|
||||
return GLI_bPickPoly4( p_stSouris,
|
||||
&stRect.tdsSommet[0],
|
||||
&stRect.tdsSommet[1],
|
||||
&stRect.tdsSommet[2],
|
||||
&stRect.tdsSommet[3] );
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bPickLine( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdsLine *p_stLine )
|
||||
{
|
||||
TDE_tdxAngle xAngle;
|
||||
TDE_tdsVertex stP1, stP2;
|
||||
|
||||
// calcul des sommets P1 et P2 du segment
|
||||
TDE_vGetTranslateVertexMatrix(&stSprMatrix, &stP1);
|
||||
TDE_vGetAngleMatrix(&stSprMatrix, &xAngle);
|
||||
stP2.xX = TDE_M_Mul( p_stLine->xLength, TDE_M_Cos(xAngle) );
|
||||
stP2.xY = TDE_M_Mul( p_stLine->xLength, TDE_M_Sin(xAngle) );
|
||||
TDE_vAddVertexToVertex(&stP1, &stP2, &stP2);
|
||||
|
||||
return GLI_bPickSegment( p_stSouris, &stP1, &stP2 );
|
||||
}
|
||||
|
||||
|
||||
BOOL GLI_bIsObjectPick( TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdeType eType,
|
||||
void *p_stObject,
|
||||
TDE_tdxPixel *p_Color )
|
||||
{
|
||||
switch(eType)
|
||||
{
|
||||
case TDE_eOT_SPRITE :
|
||||
//return GLI_bPickSprite( p_stSouris, (TDE_tdsSprite *)p_stObject );
|
||||
return GLI_bPickSpriteAbs( p_stSouris, (TDE_tdsSprite *)p_stObject, p_Color );
|
||||
break;
|
||||
|
||||
case TDE_eOT_LINE :
|
||||
return GLI_bPickLine( p_stSouris, (TDE_tdsLine *)p_stObject );
|
||||
break;
|
||||
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*On trouve dans a_tdxSprObjPick[] les indices des fils successifs
|
||||
pour arriver a l'objet sous la souris
|
||||
le premier fils porte le numero 1 */
|
||||
BOOL TDE_bGetSuperObjectPick( GLD_tdpstViewportAttributes p_stViewAttrib,
|
||||
TDE_tdsVertex *p_stSouris,
|
||||
TDE_tdstPickInfo *p_stPickInfo )
|
||||
{
|
||||
TDE_tdsSuperObject *p_stSprObjInter, *p_stSprObjPick;
|
||||
BOOL ret = FALSE;
|
||||
TDE_tdxPixel xColor;
|
||||
int i;
|
||||
|
||||
p_stPickInfo->iNbSprPick = 0;
|
||||
lViewPortW = p_stViewAttrib->dwWidth;
|
||||
lViewPortH = p_stViewAttrib->dwHeight;
|
||||
p_stSprObjPick = NULL;
|
||||
|
||||
for(i=0 ; i<TDE_kMAXPRIORITY ; i++)
|
||||
{
|
||||
p_stSprObjInter = TDE_g_apZList[i];
|
||||
|
||||
while (p_stSprObjInter != NULL)
|
||||
{
|
||||
stSprMatrix = p_stSprObjInter->stModifiedMatrix;
|
||||
|
||||
ret = GLI_bIsObjectPick(p_stSouris, p_stSprObjInter->eType, p_stSprObjInter->p_vPointer, &xColor);
|
||||
if(ret)
|
||||
{
|
||||
int j;
|
||||
|
||||
j=p_stPickInfo->iNbSprPick-1;
|
||||
while(j >= 0)
|
||||
{
|
||||
if( j < (TDE_kMAXPICK-1) )
|
||||
p_stPickInfo->aDEF_stInfo[j+1] = p_stPickInfo->aDEF_stInfo[j];
|
||||
j--;
|
||||
}
|
||||
|
||||
if ( j < (TDE_kMAXPICK-1) )
|
||||
{
|
||||
p_stPickInfo->aDEF_stInfo[j+1].p_stSprObj = p_stSprObjInter;
|
||||
p_stPickInfo->aDEF_stInfo[j+1].xColor = xColor;
|
||||
if ( p_stPickInfo->iNbSprPick < TDE_kMAXPICK )
|
||||
p_stPickInfo->iNbSprPick++;
|
||||
}
|
||||
}
|
||||
|
||||
p_stSprObjInter = p_stSprObjInter->p_stNextZList;
|
||||
}
|
||||
}
|
||||
|
||||
if(p_stPickInfo->iNbSprPick != 0)
|
||||
{
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
926
Rayman_X/cpa/tempgrp/TDE/tde_rect.c
Normal file
926
Rayman_X/cpa/tempgrp/TDE/tde_rect.c
Normal file
@@ -0,0 +1,926 @@
|
||||
/*********************************************************************************************
|
||||
|
||||
RECT.CPP
|
||||
|
||||
*********************************************************************************************/
|
||||
|
||||
#include "tde.h"
|
||||
|
||||
// _asm directive only available for W11
|
||||
#define WATCOM106
|
||||
|
||||
#ifdef WATCOM106
|
||||
|
||||
void iTde_vFastBlit(long W, long H, long lP, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlit_NZ(long W, long H, long lP, long MC, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void iTde_vFastBlit(long W, long H, long lP, long *src, long *dest)
|
||||
{
|
||||
long End_Of_Line1, End_Of_Line4, End_Of_Line, Cmpt1, Cmpt2, Cmpt3, NbLines;
|
||||
// Watcom uses the registers as following :
|
||||
// eax = W
|
||||
// edx = H
|
||||
// ebx = lP
|
||||
// ecx = *src
|
||||
_asm{
|
||||
mov esi,ecx
|
||||
mov edi,dest
|
||||
|
||||
mov ecx,dest
|
||||
and ecx,0xFFFFFFFC
|
||||
add ecx,4
|
||||
mov End_Of_Line1,ecx
|
||||
sub ecx,edi
|
||||
shr ecx,1
|
||||
mov Cmpt1,ecx
|
||||
|
||||
lea ecx,[edi+eax*2]
|
||||
mov End_Of_Line,ecx
|
||||
and ecx,0xFFFFFFFC
|
||||
mov End_Of_Line4,ecx
|
||||
sub ecx,End_Of_Line1
|
||||
shr ecx,2
|
||||
mov Cmpt2,ecx
|
||||
mov ecx,End_Of_Line
|
||||
sub ecx,End_Of_Line4
|
||||
shr ecx,1
|
||||
mov Cmpt3,ecx
|
||||
Line_Loop :
|
||||
mov ecx,Cmpt1
|
||||
cmp ecx,0
|
||||
je No_Align
|
||||
Align1 :
|
||||
mov ax,word ptr[esi]
|
||||
add esi,2
|
||||
mov word ptr[edi],ax
|
||||
add edi,2
|
||||
dec ecx
|
||||
jnz Align1
|
||||
No_Align :
|
||||
mov ecx,Cmpt2
|
||||
cmp ecx,0
|
||||
je No_4x4
|
||||
L4x4 :
|
||||
mov eax,dword ptr[esi]
|
||||
add esi,4
|
||||
mov dword ptr[edi],eax
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz L4x4
|
||||
No_4x4 :
|
||||
mov ecx,Cmpt3
|
||||
cmp ecx,0
|
||||
je EndOfLine
|
||||
|
||||
Align2 :
|
||||
mov ax,word ptr[esi]
|
||||
add esi,2
|
||||
mov word ptr[edi],ax
|
||||
add edi,2
|
||||
dec ecx
|
||||
jnz Align2
|
||||
|
||||
EndOfLine :
|
||||
lea edi,[edi+ebx*2]
|
||||
dec edx
|
||||
jnz Line_Loop
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlit_NZ(long W, long H, long lP, long MC, long *src, long *dest)
|
||||
{
|
||||
long End_Of_Line1, End_Of_Line4, End_Of_Line, Cmpt1, Cmpt2, Cmpt3, NbLines;
|
||||
|
||||
lP*=2;
|
||||
_asm{
|
||||
mov eax,W
|
||||
mov ebx,H
|
||||
mov ecx,lP
|
||||
mov edx,MC
|
||||
mov esi,src
|
||||
mov edi,dest
|
||||
|
||||
mov NbLines,ebx
|
||||
mov ebx,edi
|
||||
and ebx,0FFFFFFFCh
|
||||
add ebx,4
|
||||
mov End_Of_Line1,ebx
|
||||
sub ebx,edi
|
||||
shr ebx,1
|
||||
mov Cmpt1,ebx
|
||||
|
||||
lea ebx,[edi+eax*2]
|
||||
mov End_Of_Line,ebx
|
||||
and ebx,0FFFFFFFCh
|
||||
mov End_Of_Line4,ebx
|
||||
sub ebx,End_Of_Line1
|
||||
shr ebx,2
|
||||
mov Cmpt2,ebx
|
||||
|
||||
mov ebx,End_Of_Line
|
||||
sub ebx,End_Of_Line4
|
||||
shr ebx,1
|
||||
mov Cmpt3,ebx
|
||||
|
||||
mov ebx,edx
|
||||
shl ebx,16
|
||||
mov bx,dx // ebx = [ MagicColor | MagicColor ]
|
||||
|
||||
Line_Loop :
|
||||
|
||||
mov edx,Cmpt1
|
||||
cmp edx,0
|
||||
je No_Align
|
||||
|
||||
Align1 :
|
||||
mov ax,word ptr[esi]
|
||||
cmp ax,bx
|
||||
je NoAff1
|
||||
mov word ptr[edi],ax
|
||||
NoAff1 :
|
||||
add edi,2
|
||||
add esi,2
|
||||
dec edx
|
||||
jnz Align1
|
||||
|
||||
No_Align :
|
||||
mov edx,Cmpt2
|
||||
cmp edx,0
|
||||
je No_4x4
|
||||
|
||||
L4x4 :
|
||||
mov eax,dword ptr[esi]
|
||||
mov ecx,eax // [ c1 | c2 ] XOR [ MC | MC ]
|
||||
xor ecx,ebx // c1 = MC, c2 = MC
|
||||
jz Nada //
|
||||
cmp ecx,0x010000 // at least one visible
|
||||
jb Right // if lower, c1 = MC -> draw c2
|
||||
test ecx,0xFFFF // here, c1 visible. c2 ?
|
||||
jz Left // c2 non visible
|
||||
// here -> both are visible
|
||||
Both :
|
||||
mov dword ptr[edi],eax
|
||||
jmp Nada
|
||||
|
||||
Right :
|
||||
mov word ptr[edi],ax
|
||||
jmp Nada
|
||||
|
||||
Left :
|
||||
shr eax,16
|
||||
mov word ptr[edi+2],ax
|
||||
|
||||
Nada :
|
||||
add edi,4
|
||||
add esi,4
|
||||
dec edx
|
||||
jnz L4x4
|
||||
|
||||
No_4x4 :
|
||||
mov edx,Cmpt3
|
||||
cmp edx,0
|
||||
je EndOfLine
|
||||
|
||||
Align2 :
|
||||
mov ax,word ptr[esi]
|
||||
cmp ax,bx
|
||||
je NoAff2
|
||||
mov word ptr[edi],ax
|
||||
NoAff2 :
|
||||
add edi,2
|
||||
add esi,2
|
||||
dec edx
|
||||
jnz Align2
|
||||
|
||||
EndOfLine :
|
||||
add edi,lP
|
||||
dec NbLines
|
||||
jnz Line_Loop
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void iTde_vFastBlit_Invert(long W, long H, long lP, long MC, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = ~usSpritePixel;
|
||||
else
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlit_Invert_NZ(long W, long H, long lP, long MC, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = ~usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlitClip_Invert(long W, long H, long SrcJ, long MC, long lP, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc, *p_usLine;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = p_usLine = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
p_usSrc = p_usLine;
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = ~usSpritePixel;
|
||||
else
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
p_usLine += SrcJ;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlitClip(long W, long H, long SrcJ, long lP, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc, *p_usLine;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = p_usLine = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
p_usSrc = p_usLine;
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
p_usLine += SrcJ;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlitClip_NZ(long W, long H, long SrcJ, long MC, long lP, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc, *p_usLine;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = p_usLine = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
p_usSrc = p_usLine;
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
p_usLine += SrcJ;
|
||||
}
|
||||
}
|
||||
|
||||
void iTde_vFastBlitClip_Invert_NZ(long W, long H, long SrcJ, long MC, long lP, long *src, long *dest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel usSpritePixel;
|
||||
TDE_tdxPixel *p_usDest, *p_usSrc, *p_usLine;
|
||||
|
||||
p_usDest = (TDE_tdxPixel *)(dest);
|
||||
p_usSrc = p_usLine = (TDE_tdxPixel *)(src);
|
||||
|
||||
for (sj=0; sj<H; sj++)
|
||||
{
|
||||
p_usSrc = p_usLine;
|
||||
for (si=0; si<W; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSrc;
|
||||
if (usSpritePixel!=MC)
|
||||
*p_usDest = ~usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSrc++;
|
||||
}
|
||||
p_usDest += lP;
|
||||
p_usLine += SrcJ;
|
||||
}
|
||||
}
|
||||
|
||||
void iTDE_vFillsRect(TDE_tdsRect *Rect, TDE_tdxValue xCornerX, TDE_tdxValue xCornerY, TDE_tdxValue xWidth, TDE_tdxValue xHeight)
|
||||
{
|
||||
(*Rect).tdsSommet[0].xX = xCornerX;
|
||||
(*Rect).tdsSommet[0].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[1].xX = xCornerX + xWidth-1;
|
||||
(*Rect).tdsSommet[1].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[2].xX = xCornerX + xWidth-1;
|
||||
(*Rect).tdsSommet[2].xY = xCornerY + xHeight-1;
|
||||
|
||||
(*Rect).tdsSommet[3].xX = xCornerX;
|
||||
(*Rect).tdsSommet[3].xY = xCornerY + xHeight-1;
|
||||
}
|
||||
|
||||
void iTDE_vFillsLRect(TDE_tdsRect *Rect, TDE_tdxValue xCornerX, TDE_tdxValue xCornerY, TDE_tdxValue xWidth, TDE_tdxValue xHeight)
|
||||
{
|
||||
(*Rect).tdsSommet[0].xX = xCornerX;
|
||||
(*Rect).tdsSommet[0].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[1].xX = xCornerX + xWidth-1;
|
||||
(*Rect).tdsSommet[1].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[2].xX = xCornerX + xWidth-1;
|
||||
(*Rect).tdsSommet[2].xY = xCornerY + xHeight-1;
|
||||
|
||||
(*Rect).tdsSommet[3].xX = xCornerX;
|
||||
(*Rect).tdsSommet[3].xY = xCornerY + xHeight-1;
|
||||
}
|
||||
|
||||
void iTDE_vPercentToAbsoluteRect(TDE_tdsRect *Rect, GLD_tdpstViewportAttributes p_stViewAttrib)
|
||||
{
|
||||
short si;
|
||||
|
||||
for (si=0; si<4; si++)
|
||||
{
|
||||
(*Rect).tdsSommet[si].xX = TDE_M_Mul( (*Rect).tdsSommet[si].xX , p_stViewAttrib->dwWidth );
|
||||
(*Rect).tdsSommet[si].xY = TDE_M_Mul( (*Rect).tdsSommet[si].xY , p_stViewAttrib->dwHeight );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void iTDE_vMoveRect(TDE_tdsRect *Rect, TDE_tdxValue xTx, TDE_tdxValue xTy)
|
||||
{
|
||||
(*Rect).tdsSommet[0].xX += xTx;
|
||||
(*Rect).tdsSommet[0].xY += xTy;
|
||||
|
||||
(*Rect).tdsSommet[1].xX += xTx;
|
||||
(*Rect).tdsSommet[1].xY += xTy;
|
||||
|
||||
(*Rect).tdsSommet[2].xX += xTx;
|
||||
(*Rect).tdsSommet[2].xY += xTy;
|
||||
|
||||
(*Rect).tdsSommet[3].xX += xTx;
|
||||
(*Rect).tdsSommet[3].xY += xTy;
|
||||
}
|
||||
|
||||
void iTDE_vChangeRectCorner(TDE_tdsRect *Rect, TDE_tdxValue xCornerX, TDE_tdxValue xCornerY)
|
||||
{
|
||||
TDE_tdxValue xW, xH;
|
||||
|
||||
xW = ((*Rect).tdsSommet[1].xX) - ((*Rect).tdsSommet[0].xX);
|
||||
xH = ((*Rect).tdsSommet[3].xY) - ((*Rect).tdsSommet[0].xY);
|
||||
|
||||
(*Rect).tdsSommet[0].xX = xCornerX;
|
||||
(*Rect).tdsSommet[0].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[1].xX = xCornerX + xW;
|
||||
(*Rect).tdsSommet[1].xY = xCornerY;
|
||||
|
||||
(*Rect).tdsSommet[2].xX = xCornerX + xW;
|
||||
(*Rect).tdsSommet[2].xY = xCornerY + xH;
|
||||
|
||||
(*Rect).tdsSommet[3].xX = xCornerX;
|
||||
(*Rect).tdsSommet[3].xY = xCornerY + xH;
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vAdjustRectToFlip(TDE_tdsRect *Rect, TDE_tdsRect *FlippedRect, char cFlip)
|
||||
{
|
||||
switch (cFlip)
|
||||
{
|
||||
case 0: // no flip
|
||||
*FlippedRect = *Rect;
|
||||
return;
|
||||
case 1: // left|right
|
||||
(*FlippedRect).tdsSommet[1] = (*Rect).tdsSommet[0];
|
||||
(*FlippedRect).tdsSommet[0] = (*Rect).tdsSommet[1];
|
||||
(*FlippedRect).tdsSommet[3] = (*Rect).tdsSommet[2];
|
||||
(*FlippedRect).tdsSommet[2] = (*Rect).tdsSommet[3];
|
||||
(*FlippedRect).p_usPointer = (*Rect).p_usPointer;
|
||||
(*FlippedRect).lPitch = (*Rect).lPitch;
|
||||
return;
|
||||
case 2: // up|down
|
||||
(*FlippedRect).tdsSommet[3] = (*Rect).tdsSommet[0];
|
||||
(*FlippedRect).tdsSommet[2] = (*Rect).tdsSommet[1];
|
||||
(*FlippedRect).tdsSommet[1] = (*Rect).tdsSommet[2];
|
||||
(*FlippedRect).tdsSommet[0] = (*Rect).tdsSommet[3];
|
||||
(*FlippedRect).p_usPointer = (*Rect).p_usPointer;
|
||||
(*FlippedRect).lPitch = (*Rect).lPitch;
|
||||
return;
|
||||
case 3: // left|right & up|down
|
||||
(*FlippedRect).tdsSommet[2] = (*Rect).tdsSommet[0];
|
||||
(*FlippedRect).tdsSommet[3] = (*Rect).tdsSommet[1];
|
||||
(*FlippedRect).tdsSommet[0] = (*Rect).tdsSommet[2];
|
||||
(*FlippedRect).tdsSommet[1] = (*Rect).tdsSommet[3];
|
||||
(*FlippedRect).p_usPointer = (*Rect).p_usPointer;
|
||||
(*FlippedRect).lPitch = (*Rect).lPitch;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vAdjustScreenRectForClip(TDE_tdsRect *Rect, TDE_tdsRect *ClippedRect, long lViewPortW, long lViewPortH)
|
||||
{
|
||||
*ClippedRect = *Rect;
|
||||
|
||||
if ( Rect->tdsSommet[0].xX<0 )
|
||||
(*ClippedRect).tdsSommet[0].xX = (*ClippedRect).tdsSommet[3].xX = 0;
|
||||
if ( Rect->tdsSommet[1].xX>lViewPortW )
|
||||
(*ClippedRect).tdsSommet[1].xX = (*ClippedRect).tdsSommet[2].xX = lViewPortW;
|
||||
|
||||
if ( Rect->tdsSommet[0].xY<0 )
|
||||
(*ClippedRect).tdsSommet[0].xY = (*ClippedRect).tdsSommet[1].xY = 0;
|
||||
if ( Rect->tdsSommet[3].xY>lViewPortH )
|
||||
(*ClippedRect).tdsSommet[3].xY = (*ClippedRect).tdsSommet[2].xY = lViewPortH;
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vAdjustScreenRectToClipRect(TDE_tdsRect *Rect, TDE_tdsRect *ClippedRect, TDE_tdsRect *stClipSq)
|
||||
{
|
||||
*ClippedRect = *Rect;
|
||||
|
||||
if ( Rect->tdsSommet[0].xX < stClipSq->tdsSommet[0].xX )
|
||||
(*ClippedRect).tdsSommet[0].xX = (*ClippedRect).tdsSommet[3].xX = stClipSq->tdsSommet[0].xX;
|
||||
if ( Rect->tdsSommet[1].xX > stClipSq->tdsSommet[1].xX )
|
||||
(*ClippedRect).tdsSommet[1].xX = (*ClippedRect).tdsSommet[2].xX = stClipSq->tdsSommet[1].xX;
|
||||
|
||||
if ( Rect->tdsSommet[0].xY < stClipSq->tdsSommet[0].xY )
|
||||
(*ClippedRect).tdsSommet[0].xY = (*ClippedRect).tdsSommet[1].xY = stClipSq->tdsSommet[0].xY;
|
||||
if ( Rect->tdsSommet[3].xY > stClipSq->tdsSommet[3].xY )
|
||||
(*ClippedRect).tdsSommet[3].xY = (*ClippedRect).tdsSommet[2].xY = stClipSq->tdsSommet[3].xY;
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vAdjustSourceRectForClip(TDE_tdsRect *ScreenRect, TDE_tdsRect *SrcRect, TDE_tdsRect *SrcClippedRect, long lViewPortW, long lViewPortH)
|
||||
{
|
||||
TDE_tdxValue xScaledSourceW, xScaledSourceH, xScaledSpriteW, xScaledSpriteH, xDec;
|
||||
|
||||
*SrcClippedRect = *SrcRect;
|
||||
|
||||
// Signed source dimensions
|
||||
xScaledSourceW = (*SrcRect).tdsSommet[1].xX - (*SrcRect).tdsSommet[0].xX;
|
||||
xScaledSourceH = (*SrcRect).tdsSommet[3].xY - (*SrcRect).tdsSommet[0].xY;
|
||||
|
||||
// Screen sprite dimensions
|
||||
xScaledSpriteW = (*ScreenRect).tdsSommet[1].xX - (*ScreenRect).tdsSommet[0].xX;
|
||||
xScaledSpriteH = (*ScreenRect).tdsSommet[3].xY - (*ScreenRect).tdsSommet[0].xY;
|
||||
|
||||
// Adjust source rectangle for clipping
|
||||
if ( (*ScreenRect).tdsSommet[0].xX<0 )
|
||||
{
|
||||
xDec = ((*ScreenRect).tdsSommet[0].xX * xScaledSourceW / xScaledSpriteW);
|
||||
(*SrcClippedRect).tdsSommet[0].xX -= xDec;
|
||||
(*SrcClippedRect).tdsSommet[3].xX -= xDec;
|
||||
}
|
||||
|
||||
if ( (*ScreenRect).tdsSommet[1].xX>lViewPortW )
|
||||
{
|
||||
xDec = (((*ScreenRect).tdsSommet[1].xX - lViewPortW) * xScaledSourceW / xScaledSpriteW);
|
||||
(*SrcClippedRect).tdsSommet[1].xX -= xDec;
|
||||
(*SrcClippedRect).tdsSommet[2].xX -= xDec;
|
||||
}
|
||||
|
||||
if ( (*ScreenRect).tdsSommet[0].xY<0 )
|
||||
{
|
||||
xDec = ((*ScreenRect).tdsSommet[0].xY * xScaledSourceH / xScaledSpriteH);
|
||||
(*SrcClippedRect).tdsSommet[0].xY -= xDec;
|
||||
(*SrcClippedRect).tdsSommet[1].xY -= xDec;
|
||||
}
|
||||
|
||||
if ( (*ScreenRect).tdsSommet[3].xY>lViewPortH )
|
||||
{
|
||||
xDec = (((*ScreenRect).tdsSommet[3].xY - lViewPortH) * xScaledSourceH / xScaledSpriteH);
|
||||
(*SrcClippedRect).tdsSommet[2].xY -= xDec;
|
||||
(*SrcClippedRect).tdsSommet[3].xY -= xDec;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void iTDE_vBlit(TDE_tdsRect *RectSource, TDE_tdsRect *RectDest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, usSpritePixel;
|
||||
long lScaledSpriteW, lScaledSpriteH,
|
||||
ldE, lE, lF, ldF, lPitchSrc, lPitchDest;
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xScaledSourceW, xScaledSourceH;
|
||||
TDE_tdl1616 lHorzOrigin, lVertOrigin, lHorzIncrement, lVertIncrement, lU;
|
||||
|
||||
p_usSource = RectSource->p_usPointer;
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
xScaledSpriteW = RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX;
|
||||
xScaledSpriteH = RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY;
|
||||
lScaledSpriteW = TDE_M_ValueToLong( xScaledSpriteW );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( xScaledSpriteH );
|
||||
xScaledSourceW = RectSource->tdsSommet[1].xX - RectSource->tdsSommet[0].xX;
|
||||
xScaledSourceH = RectSource->tdsSommet[3].xY - RectSource->tdsSommet[0].xY;
|
||||
|
||||
lHorzIncrement = TDE_M_ValueTo1616( TDE_M_Div( xScaledSourceW , xScaledSpriteW) );
|
||||
lVertIncrement = TDE_M_ValueTo1616( TDE_M_Div( xScaledSourceH , xScaledSpriteH) );
|
||||
lHorzOrigin = lU = TDE_M_ValueTo1616( RectSource->tdsSommet[0].xX);
|
||||
lVertOrigin = TDE_M_ValueTo1616( RectSource->tdsSommet[0].xY);
|
||||
|
||||
lPitchSrc = RectSource->lPitch;
|
||||
lPitchDest = (RectDest->lPitch)-lScaledSpriteW;
|
||||
|
||||
lE = lPitchSrc*(lVertOrigin>>16);
|
||||
ldE = lPitchSrc*(lVertIncrement>>16);
|
||||
lF = (lVertOrigin>>1)&0x7FFF;
|
||||
ldF = (lVertIncrement>>1)&0x7FFF;
|
||||
|
||||
for (sj=0; sj<lScaledSpriteH; sj++)
|
||||
{
|
||||
for (si=0; si<lScaledSpriteW; si++)
|
||||
{
|
||||
usSpritePixel = *(p_usSource+lE+(lU>>16));
|
||||
//if (usSpritePixel>0)
|
||||
*p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
lU += lHorzIncrement;
|
||||
}
|
||||
lU = lHorzOrigin;
|
||||
lE += ldE;
|
||||
lF += ldF;
|
||||
if (lF&0x8000)
|
||||
{
|
||||
lF &= 0x7FFF;
|
||||
lE += lPitchSrc;
|
||||
}
|
||||
|
||||
p_usDest += lPitchDest;
|
||||
}
|
||||
}
|
||||
|
||||
void iTDE_vBlitFast(TDE_tdsRect *RectSource, TDE_tdsRect *RectDest)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, usSpritePixel;
|
||||
long lScaledSpriteW, lScaledSpriteH, lSrcIncr, lDestIncr;
|
||||
|
||||
lScaledSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY );
|
||||
|
||||
p_usSource = (RectSource->p_usPointer) + (long)((RectSource->lPitch)*(RectSource->tdsSommet[0].xY) + (RectSource->tdsSommet[0].xX));
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScaledSpriteW;
|
||||
lSrcIncr = RectSource->lPitch - lScaledSpriteW;
|
||||
|
||||
for (sj=0; sj<lScaledSpriteH; sj++)
|
||||
{
|
||||
for (si=0; si<lScaledSpriteW; si++)
|
||||
{
|
||||
usSpritePixel = *p_usSource;
|
||||
if (usSpritePixel>0) *p_usDest = usSpritePixel;
|
||||
p_usDest++;
|
||||
p_usSource++;
|
||||
}
|
||||
p_usDest += lDestIncr;
|
||||
p_usSource += lSrcIncr;
|
||||
}
|
||||
}
|
||||
|
||||
void iTDE_vBlitFastMemory(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
long lScaledSpriteW, lScaledSpriteH, lDestIncr;
|
||||
|
||||
lScaledSpriteW = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( Source->stDim.xY );
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScaledSpriteW;
|
||||
|
||||
iTde_vFastBlit(lScaledSpriteW, lScaledSpriteH, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitClipMemory(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
long lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr;
|
||||
|
||||
lScreenSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX + 1);
|
||||
lScreenSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY + 1);
|
||||
lSrcJump = TDE_M_ValueToLong( Source->stDim.xX);
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScreenSpriteW;
|
||||
|
||||
iTde_vFastBlitClip(lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
// clipping along a rectangle
|
||||
void iTDE_vBlitClipMemory2(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
long lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr;
|
||||
|
||||
lScreenSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX + 1);
|
||||
lScreenSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY + 1);
|
||||
lSrcJump = TDE_M_ValueToLong( Source->stDim.xX);
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScreenSpriteW;
|
||||
|
||||
iTde_vFastBlitClip(lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vBlitClipMemory_NZ(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, xMagicColor;
|
||||
long lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr;
|
||||
|
||||
lScreenSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX + 1 );
|
||||
lScreenSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY + 1 );
|
||||
lSrcJump = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
xMagicColor = Source->xMagicColor;
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScreenSpriteW;
|
||||
|
||||
iTde_vFastBlitClip_NZ(lScreenSpriteW, lScreenSpriteH, lSrcJump, (long) xMagicColor, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitClipMemory_Invert(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, xMagicColor;
|
||||
long lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr;
|
||||
|
||||
lScreenSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX + 1 );
|
||||
lScreenSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY + 1 );
|
||||
lSrcJump = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
xMagicColor = Source->xMagicColor;
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScreenSpriteW;
|
||||
|
||||
iTde_vFastBlitClip_Invert(lScreenSpriteW, lScreenSpriteH, lSrcJump, (long) xMagicColor, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitClipMemory_Invert_NZ(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, xMagicColor;
|
||||
long lScreenSpriteW, lScreenSpriteH, lSrcJump, lDestIncr;
|
||||
|
||||
lScreenSpriteW = TDE_M_ValueToLong( RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX + 1 );
|
||||
lScreenSpriteH = TDE_M_ValueToLong( RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY + 1 );
|
||||
lSrcJump = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
xMagicColor = Source->xMagicColor;
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScreenSpriteW;
|
||||
|
||||
iTde_vFastBlitClip_Invert_NZ(lScreenSpriteW, lScreenSpriteH, lSrcJump, (long) xMagicColor, lDestIncr, (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitFastMemory_NZ(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
TDE_tdxPixel usMagicColor;
|
||||
long lScaledSpriteW, lScaledSpriteH, lDestIncr;
|
||||
|
||||
lScaledSpriteW = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( Source->stDim.xY );
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScaledSpriteW;
|
||||
usMagicColor = Source->xMagicColor;
|
||||
|
||||
iTde_vFastBlit_NZ(lScaledSpriteW, lScaledSpriteH, lDestIncr, (long)(usMagicColor), (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitFastMemory_Invert(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
TDE_tdxPixel usMagicColor;
|
||||
long lScaledSpriteW, lScaledSpriteH, lDestIncr;
|
||||
|
||||
lScaledSpriteW = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( Source->stDim.xY );
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScaledSpriteW;
|
||||
usMagicColor = Source->xMagicColor;
|
||||
|
||||
iTde_vFastBlit_Invert(lScaledSpriteW, lScaledSpriteH, lDestIncr, (long)(usMagicColor), (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
void iTDE_vBlitFastMemory_Invert_NZ(TDE_tdsMemZone *Source, TDE_tdsRect *RectDest)
|
||||
{
|
||||
TDE_tdxPixel *p_usDest, *p_usSource;
|
||||
TDE_tdxPixel usMagicColor;
|
||||
long lScaledSpriteW, lScaledSpriteH, lDestIncr;
|
||||
|
||||
lScaledSpriteW = TDE_M_ValueToLong( Source->stDim.xX );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( Source->stDim.xY );
|
||||
|
||||
p_usSource = (Source->p_usPointer);
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
lDestIncr = RectDest->lPitch - lScaledSpriteW;
|
||||
usMagicColor = Source->xMagicColor;
|
||||
|
||||
iTde_vFastBlit_Invert_NZ(lScaledSpriteW, lScaledSpriteH, lDestIncr, (long)(usMagicColor), (long *)p_usSource, (long *)p_usDest);
|
||||
}
|
||||
|
||||
|
||||
void iTDE_vBlit_Transparency(TDE_tdsRect *RectSource, TDE_tdsRect *RectDest, TDE_tdxValue xAlpha)
|
||||
{
|
||||
short si, sj;
|
||||
TDE_tdxPixel *p_usDest, *p_usSource, usSpritePixel, usBackPixel;
|
||||
long lScaledSpriteW, lScaledSpriteH,
|
||||
ldE, lE, lF, ldF, lPitchSrc, lPitchDest;
|
||||
TDE_tdxValue xScaledSpriteW, xScaledSpriteH, xScaledSourceW, xScaledSourceH;
|
||||
TDE_tdl1616 lHorzOrigin, lVertOrigin, lHorzIncrement, lVertIncrement, lU;
|
||||
|
||||
// Variables for alpha-transparency
|
||||
short sBlueMask = 0x001F; // 0000 0000 0001 1111 -> obtain blue component
|
||||
short sGreenMask = 0x7E0; // 0000 0111 1110 0000 -> obtain green component
|
||||
// short sRedMask = 0xF800; // 1111 1000 0000 0000 -> obtain red component
|
||||
short sB, sG, sR;
|
||||
char cIndix1, cIndix2;
|
||||
unsigned char *p_cAcc15, *p_cAcc25, *p_cAcc16, *p_cAcc26;
|
||||
|
||||
p_usSource = RectSource->p_usPointer;
|
||||
p_usDest = RectDest->p_usPointer +
|
||||
(TDE_M_ValueToLong(RectDest->lPitch)) * (TDE_M_ValueToLong(RectDest->tdsSommet[0].xY)) + TDE_M_ValueToLong(RectDest->tdsSommet[0].xX);
|
||||
|
||||
xScaledSpriteW = RectDest->tdsSommet[1].xX - RectDest->tdsSommet[0].xX;
|
||||
xScaledSpriteH = RectDest->tdsSommet[3].xY - RectDest->tdsSommet[0].xY;
|
||||
lScaledSpriteW = TDE_M_ValueToLong( xScaledSpriteW );
|
||||
lScaledSpriteH = TDE_M_ValueToLong( xScaledSpriteH );
|
||||
xScaledSourceW = RectSource->tdsSommet[1].xX - RectSource->tdsSommet[0].xX;
|
||||
xScaledSourceH = RectSource->tdsSommet[3].xY - RectSource->tdsSommet[0].xY;
|
||||
|
||||
lHorzIncrement = TDE_M_ValueTo1616( TDE_M_Div( xScaledSourceW , xScaledSpriteW) );
|
||||
lVertIncrement = TDE_M_ValueTo1616( TDE_M_Div( xScaledSourceH , xScaledSpriteH) );
|
||||
lHorzOrigin = lU = TDE_M_ValueTo1616( RectSource->tdsSommet[0].xX);
|
||||
lVertOrigin = TDE_M_ValueTo1616( RectSource->tdsSommet[0].xY);
|
||||
|
||||
lPitchSrc = RectSource->lPitch;
|
||||
lPitchDest = (RectDest->lPitch)-lScaledSpriteW;
|
||||
|
||||
lE = lPitchSrc*(lVertOrigin>>16);
|
||||
ldE = lPitchSrc*(lVertIncrement>>16);
|
||||
lF = (lVertOrigin>>1)&0x7FFF;
|
||||
ldF = (lVertIncrement>>1)&0x7FFF;
|
||||
|
||||
cIndix1 = ((char)(xAlpha*64))&0x3F;
|
||||
cIndix2 = 63-cIndix1;
|
||||
p_cAcc15 = &(a_cTransparencyTable5[cIndix1][0]);
|
||||
p_cAcc25 = &(a_cTransparencyTable5[cIndix2][0]);
|
||||
p_cAcc16 = &(a_cTransparencyTable6[cIndix1][0]);
|
||||
p_cAcc26 = &(a_cTransparencyTable6[cIndix2][0]);
|
||||
|
||||
for (sj=0; sj<lScaledSpriteH; sj++)
|
||||
{
|
||||
for (si=0; si<lScaledSpriteW; si++)
|
||||
{
|
||||
usSpritePixel = *(p_usSource+lE+(lU>>16));
|
||||
if (usSpritePixel>0)
|
||||
{
|
||||
usBackPixel = *p_usDest;
|
||||
/*
|
||||
usSpritePixel = (usSpritePixel & sMasque_565)>>1;
|
||||
usBackPixel = (usBackPixel & sMasque_565)>>1;
|
||||
*p_usDest = usSpritePixel + usBackPixel;
|
||||
*/
|
||||
sB = *(p_cAcc15 + (usBackPixel & sBlueMask)) + *(p_cAcc25+ (usSpritePixel & sBlueMask));
|
||||
sG = *(p_cAcc16 + ((usBackPixel & sGreenMask)>>5)) + *(p_cAcc26 + ((usSpritePixel & sGreenMask)>>5));
|
||||
sR = *(p_cAcc15 + (usBackPixel>>11)) + *(p_cAcc25 + (usSpritePixel>>11));
|
||||
*p_usDest = sB+(sG<<5)+(sR<<11);
|
||||
}
|
||||
p_usDest++;
|
||||
lU += lHorzIncrement;
|
||||
}
|
||||
lU = lHorzOrigin;
|
||||
lE += ldE;
|
||||
lF += ldF;
|
||||
if (lF&0x8000)
|
||||
{
|
||||
lF &= 0x7FFF;
|
||||
lE += lPitchSrc;
|
||||
}
|
||||
|
||||
p_usDest += lPitchDest;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user