Files
Work/engine/SCRAPS.TXT
2024-08-07 09:16:27 -04:00

553 lines
20 KiB
Plaintext

void PureViewSystem::mapCoordinates(Point3D &firstPoint3D,Point &firstPoint)
{
Point3D point3D(firstPoint3D);
Point point(firstPoint);
initView((PureViewSystem*)this);
::mapCoordinates(&point3D,&point,TRUE);
firstPoint3D=point3D;
firstPoint=point;
}
Cache STRUC
Cache@@mColRow DD ?
Cache@@mCacheData DB ?
Cache@@mCacheStatus DB ?
Cache ENDS
GetCacheData STRUC
GetCacheData@@mColRow DD ?
GetCacheData@@mCacheData DB ?
GetCacheData ENDS
GetCache STRUC
GetCache@@mCacheStatus DB ?
GetCache@@mCacheHits DD ?
GetCache@@mCacheData GetCacheData 05h DUP(?)
GetCache ENDS
if 0
roundEBX [esi].PureMap@@mySource ; convert and round PureMap@@mySource -> ebx (row)
roundEAX [esi].PureMap@@mxSource ; convert and round PureMap@@mxSource -> eax (col)
getSrcDataByte MACRO ; BYTE getSrcDataByte(eax=colRow)
mov ebx,eax ; move colRow to ebx register
multiply bx,bmData@@mSrcWidth ; multiply (row*width)-> eax
movzx edx,bmData@@mSrcWidth ; move width to edx register
add eax,edx ; add in width (ie) (row*width)+width
mov edx,bmData@@mSrcExtent ; move source bitmap extent to edx
sub edx,eax ; sub result from source bmp extent
shr ebx,10h ; ebx gets column
add edx,ebx ; add column back in
mov ebx,bmData@@mlpSrcPtr ; move mlpSrcPtr to ebx register
mov cl,byte ptr[ebx+edx] ; get source byte at ebx+edx to cl
ENDM
endif
bmData@@mMulCache MathCache ?
bmData@@mDivCache MathCache ?
;bmData@@mMulCacheOne DD 00h
;bmData@@mMulCacheTwo DD 00h
;bmData@@mMulCacheVal DD 00h
if 0
multiply MACRO varOne,varTwo
LOCAL @@bypassCache,@@return
movzx eax,varOne ; move varOne into eax register
movzx edx,varTwo ; move varTwo into ebx register
cmp eax,bmData@@mMulCache.MathCache@@mCacheOne ; check first cache item
jne @@bypassCache ; if no hit then perform multiply
cmp edx,bmData@@mMulCache.MathCache@@mCacheTwo ; check second cache item
jne @@bypassCache ; if no hit then perform multiply
mov eax,bmData@@mMulCache.MathCache@@mCacheVal ; cache hit returns associated value
jmp @@return ; we're all through here
@@bypassCache: ; bypass cache sync address
mov bmData@@mMulCache.MathCache@@mCacheOne,eax ; move first param to cache item one
mov bmData@@mMulCache.MathCache@@mCacheTwo,edx ; move second param to cache item two
imul eax,edx ; perform multiply, result to eax
mov bmData@@mMulCache.MathCache@@mCacheVal,eax ; store result to cache
@@return: ; return sync address
ENDM
endif
if 0
divide MACRO varOne,varTwo
LOCAL @@bypassCache,@@return
mov eax,varOne
mov edx,varTwo
cmp eax,bmData@@mDivCache.MathCache@@mCacheOne ; check first cache item
jne @@bypassCache ; if no hit then perform multiply
cmp edx,bmData@@mDivCache.MathCache@@mCacheTwo ; check second cache item
jne @@bypassCache ; if no hit then perform multiply
mov eax,bmData@@mDivCache.MathCache@@mCacheVal ; cache hit returns associated value
jmp @@return ; we're all through here
@@bypassCache:
mov bmData@@mDivCache.MathCache@@mCacheOne,eax ;
mov bmData@@mDivCache.MathCache@@mCacheTwo,edx ;
cdq ; convert doubleword in eax to quadword at edx:eax
idiv varTwo ; divide eax/varTwo result to eax, remainder to edx
mov bmData@@mDivCache.MathCache@@mCacheVal,eax ; store result to cache
@@return:
ENDM
endif
mov bmData@@mMulCache.MathCache@@mCacheOne,00000000h
mov bmData@@mMulCache.MathCache@@mCacheTwo,00000000h
mov bmData@@mMulCache.MathCache@@mCacheVal,00000000h
mov bmData@@mDivCache.MathCache@@mCacheOne,00000000h
mov bmData@@mDivCache.MathCache@@mCacheTwo,00000000h
mov bmData@@mDivCache.MathCache@@mCacheVal,00000000h
void WINGBlt::line(const Point &firstPoint,const Point &secondPoint,BYTE byteValue)
{
LONG xRunning((LONG)firstPoint.x()<<0x10);
LONG yRunning((LONG)firstPoint.y()<<0x10);
LONG xDelta;
LONG yDelta;
short xDir(1);
short yDir(1);
short steps;
if(secondPoint.x()<firstPoint.x())xDir=-1;
if(secondPoint.y()<firstPoint.y())yDir=-1;
xDelta=secondPoint.x()-firstPoint.x();
yDelta=secondPoint.y()-firstPoint.y();
if(xDelta<0)xDelta=-xDelta;
if(yDelta<0)yDelta=-yDelta;
if(xDelta<yDelta)
{
xDelta<<=0x10;
if(yDelta)xDelta/=yDelta;
else xDelta=1L;
steps=yDelta;
yDelta=0x10000;
}
else
{
yDelta<<=0x10;
if(xDelta)yDelta/=xDelta;
else yDelta=1L;
steps=xDelta;
xDelta=0x10000;
}
if(-1==xDir&&-1==yDir)
{
for(short stepIndex=0;stepIndex<steps;stepIndex++)
{
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
xRunning-=xDelta;
yRunning-=yDelta;
}
}
else if(-1==xDir&&1==yDir)
{
for(short stepIndex=0;stepIndex<steps;stepIndex++)
{
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
xRunning-=xDelta;
yRunning+=yDelta;
}
}
else if(1==xDir&&-1==yDir)
{
for(short itemIndex=0;itemIndex<steps;itemIndex++)
{
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
xRunning+=xDelta;
yRunning-=yDelta;
}
}
else if(1==xDir&&1==yDir)
{
for(short itemIndex=0;itemIndex<steps;itemIndex++)
{
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
xRunning+=xDelta;
yRunning+=yDelta;
}
}
}
#if 0
Texture::Texture(const Vector3D &dstPoints,Bitmap &textureBitmap,WINGBlt &displayBitmap,Device3D &displayDevice)
: mEdgeMap(&mLeftEdge,&mRightEdge)
{
mDstPoints3D=dstPoints;
Vector3D temp3DPoint(mDstPoints3D);
Vector2D temp2DPoint(mDstPoints2D);
displayDevice.translatePoint(temp3DPoint,temp2DPoint);
mDstPoints2D=temp2DPoint;
mLeftEdge.numVertexes(Vector3D::VectorPoints);
mRightEdge.numVertexes(Vector3D::VectorPoints);
mTexturePoints[0]=Point(0,0);
mTexturePoints[1]=Point(textureBitmap.width()-1,0);
mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1);
mTexturePoints[3]=Point(0,textureBitmap.height()-1);
mLeftEdge.setSrcPoints((Point*)&mTexturePoints);
mLeftEdge.setDstPoints((Point*)&mDstPoints2D);
mRightEdge.setSrcPoints((Point*)&mTexturePoints);
mRightEdge.setDstPoints((Point*)&mDstPoints2D);
::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr());
::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),displayBitmap.getDataPtr());
}
#endif
#if 0
Texture::Texture(const Vector3D &dstPoints,Bitmap &textureBitmap,Bitmap &displayBitmap,Device3D &displayDevice)
: mEdgeMap(&mLeftEdge,&mRightEdge)
{
mDstPoints3D=dstPoints;
Vector3D temp3DPoint(mDstPoints3D);
Vector2D temp2DPoint(mDstPoints2D);
displayDevice.translatePoint(temp3DPoint,temp2DPoint);
mDstPoints2D=temp2DPoint;
mLeftEdge.numVertexes(Vector3D::VectorPoints);
mRightEdge.numVertexes(Vector3D::VectorPoints);
mTexturePoints[0]=Point(0,0);
mTexturePoints[1]=Point(textureBitmap.width()-1,0);
mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1);
mTexturePoints[3]=Point(0,textureBitmap.height()-1);
mLeftEdge.setSrcPoints((Point*)&mTexturePoints);
mLeftEdge.setDstPoints((Point*)&mDstPoints2D);
mRightEdge.setSrcPoints((Point*)&mTexturePoints);
mRightEdge.setDstPoints((Point*)&mDstPoints2D);
::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr());
::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),displayBitmap.getDataPtr());
}
#endif
#ifndef _ENGINE_SYSTEMOBJECT_HPP_
#define _ENGINE_SYSTEMOBJECT_HPP_
#ifndef _COMMON_VECTOR3D_HPP_
#include <common/vector3d.hpp>
#endif
#ifndef _COMMON_VECTOR2D_HPP_
#include <common/vector2d.hpp>
#endif
class SystemObject : public Vector3D
#if 0
class SystemObject
{
public:
enum Type{TypeSprite,TypeTexture,TypeUnknown};
enum Disposition{Active,Destroyed,Idle};
SystemObject(void);
SystemObject(Vector3D &currentWorldPosition,Vector2D &currentScreenPosition,Type typeInfo);
virtual ~SystemObject();
void worldPosition(Vector3D worldPosition);
void screenPosition(Vector2D screenPosition);
void type(Type type);
void disposition(Disposition disposition);
Vector3D worldPosition(void)const;
Vector2D screenPosition(void)const;
Vector3D prevWorldPosition(void)const;
Vector2D prevScreenPosition(void)const;
Type type(void)const;
Disposition disposition(void)const;
private:
Type mType;
Disposition mDisposition;
Vector3D mCurrentWorldPosition;
Vector3D mLastWorldPosition;
Vector2D mCurrentScreenPosition;
Vector2D mLastScreenPosition;
};
inline
SystemObject::SystemObject(void)
: mType(TypeUnknown), mDisposition(Idle)
{
}
inline
SystemObject::SystemObject(Vector3D &currentWorldPosition,Vector2D &currentScreenPosition,Type type)
: mCurrentWorldPosition(currentWorldPosition), mLastWorldPosition(currentWorldPosition),
mCurrentScreenPosition(currentScreenPosition), mLastScreenPosition(currentScreenPosition), mType(type)
{
}
inline
SystemObject::~SystemObject()
{
}
inline
void SystemObject::worldPosition(Vector3D worldPosition)
{
mLastWorldPosition=mCurrentWorldPosition;
mCurrentWorldPosition=worldPosition;
}
inline
void SystemObject::screenPosition(Vector2D screenPosition)
{
mLastScreenPosition=mCurrentScreenPosition;
mCurrentScreenPosition=screenPosition;
}
inline
void SystemObject::type(SystemObject::Type type)
{
mType=type;
}
inline
void SystemObject::disposition(SystemObject::Disposition disposition)
{
mDisposition=disposition;
}
inline
Vector3D SystemObject::worldPosition(void)const
{
return mCurrentWorldPosition;
}
inline
Vector2D SystemObject::screenPosition(void)const
{
return mCurrentScreenPosition;
}
inline
Vector3D SystemObject::prevWorldPosition(void)const
{
return mLastWorldPosition;
}
inline
Vector2D SystemObject::prevScreenPosition(void)const
{
return mLastScreenPosition;
}
inline
SystemObject::Type SystemObject::type(void)const
{
return mType;
}
inline
SystemObject::Disposition SystemObject::disposition(void)const
{
return mDisposition;
}
#endif
#endif
Point3D first3DPoint(((Vector3D&)(someRect3D.firstPlane()))[0]);
Point3D next3DPoint(((Vector3D&)(someRect3D.firstPlane()))[2]);
Point first2DPoint;
Point next2DPoint;
mapCoordinates(first3DPoint,first2DPoint);
mapCoordinates(next3DPoint,next2DPoint);
floodFill(first2DPoint.midPoint(next2DPoint),RGBColor(0,0,255),RGBColor(255,0,0));
void PureViewSystem::translatePoint(const Vector3D &vector3D,Vector2D &vector2D,MapMode mapMode)
{
::initView((PureViewSystem*)this);
::mapVectorCoordinates(&((Vector3D&)vector3D)[0],&vector2D[0],(DWORD)mapMode);
// ::mapCoordinates(&((Vector3D&)vector3D)[0],&vector2D[0],(DWORD)mapMode);
// ::mapCoordinates(&((Vector3D&)vector3D)[1],&vector2D[1],(DWORD)mapMode);
// ::mapCoordinates(&((Vector3D&)vector3D)[2],&vector2D[2],(DWORD)mapMode);
// ::mapCoordinates(&((Vector3D&)vector3D)[3],&vector2D[3],(DWORD)mapMode);
}
;_clearWINGBlt proc near ; void clearWINGBlt(DWORD lpWINGData,DWORD imageExtent)
; push edi ; save destination index register
; xor eax,eax ; clear eax register
; mov edi,[esp+08h] ; move lpWINGData to esi
; mov ecx,[esp+0Ch] ; move bitmap extent to ecx
; shr ecx,02h ; divide bitmap extent by sizeof(long)
; rep stosd ; clear out the bitmap in chunks of sizeof(long)
; pop edi ; restore destination index register
; retn ; return near to caller
;_clearWINGBlt endp
_proto proc near ; void proto(Polygon3D *pPolygon3D) where Polygon3D=Block<Line3D>
push ebp ; save previous stack frame
mov ebp,esp ; create new stack frame
push edi ; save destination index register
push esi ; save source index register
mov edi,[ebp+08h] ; move pPolygon3D to destination index register
mov ecx,ASMPolygon3D[edi].Polygon3D@@mBlockLine3D.BlockLine3D@@mSize ; how many items in block
mov esi,ASMPolygon3D[edi].Polygon3D@@mBlockLine3D.BlockLine3D@@mContainer ; get to first item
@@protiter: ; iteration sync address
cmp esi,0000h ; is this a valid item
je @@endproc ; if not then we're done
mov edi,Line3DNodePtr[esi].Line3DNodePtr@@mItem ; go fetch item for this node
mov esi,Line3DNodePtr[esi].Line3DNodePtr@@mLine3DNodePtrNext ; go fetch next node
jmp @@protiter ; iterate
@@endproc: ; end proc sync address
pop esi ; restore source index register
pop edi ; restore destination index register
pop ebp ; restore previous stack frame
retn ; return near to caller
_proto endp
Polygon3D polygon3D;
for(int itemIndex=0;itemIndex<20000;itemIndex++)polygon3D.insert(&Line3D(Point3D(1,2,3),Point3D(4,5,6)));
for(int i=0;i<500;i++)mapPolygonCoordinates(&polygon3D);
return FALSE;
#if 0
if 0
_resampleClip proc near ; short resampleClip(char *lpIn,char *lpOut,DWORD inLen,DWORD outLen,DWORD outClamp)
LOCAL sampleFactor:DWORD,runningFactor:DWORD=LocalLength
push ebp ; save stack frame
mov ebp,esp ; create new stack frame
sub esp,LocalLength ; adjust stack for local
push esi ; save source index register
push edi ; save destination
push ebx ; save ebx register
mov eax,[ebp+10h] ; move inLen to eax register
cmp eax,0000h ; compare inLen to zero
jle @@errorExit ; if it's less or equal then exit
mov ebx,[ebp+14h] ; move outLen to ebx register
cmp ebx,0000h ; compare outLen to zero
jle @@errorExit ; if it's less or equal then exit
dec eax ; decrement inLen
shl eax,10h ; multiply inLen by 65536L
divide eax,ebx ; divide ((inLen-1L)*65536L)/outLen
mov sampleFactor,eax ; store the factor
dec ebx ; ebx has (outLen-1)
mov ecx,ebx ; copy (outLen-1) to ecx
mov eax,[ebp+18h] ; move outClip to eax register
sub ebx,eax ; subtract (outLen-1L)-outClip, this is clipping region
mov edi,[ebp+0Ch] ; move lpOut to destination index register
add edi,ecx ; edi=lpOut+(outLen-1L)
mov esi,[ebp+08h] ; move lpIn to source index register
multiply ecx,sampleFactor ; multiply (outLen-1)*sampleFactor
mov runningFactor,eax ; save this into runningFactor
@@loopControl: ; loop control sync address
cmp ecx,0000h ; make sure we're within boundary
jl @@exit ; if not then we exit
cmp ecx,ebx ; compare ecx to clipping region
je @@exit ; if it's equal then we're done
mov eax,runningFactor ; move last running factor into eax
round ; round it off
mov dl,byte ptr[esi+eax] ; move source byte to dl register
mov byte ptr[edi],dl ; move source byte to destination address
mov eax,sampleFactor ; move sampleFactor into eax register
sub runningFactor,eax ; subtract from running factor
dec ecx ; decrement counter
dec edi ; advance (backwards) along lpOut array
jmp @@loopControl ; continue processing
@@errorExit: ; error exit return sync address
xor ax,ax ; clear ax register on error
jmp @@endProcedure ; jump to end procedure
@@exit: ; exit sync address
mov ax,01h ; set ax register on success
@@endProcedure: ; end procedure sync address
pop ebx ; restore ebx register
pop edi ; restore destination index register
pop esi ; restore source index register
add esp,LocalLength ; remove locals off stack
pop ebp ; restore previous stack frame
retn ; return near to caller
_resampleClip endp
endif
clamp MACRO value
LOCAL @@return
cmp value,0000h
jge @@return
mov value,0000h
@@return:
ENDM
void DIB3D::fillRect(const Rect3D &someRect3D,int paletteIndex)
{
Vector2D vector2D;
mapCoordinates(((Vector3D&)someRect3D.firstPlane())[0],vector2D[0]);
mapCoordinates(((Vector3D&)someRect3D.firstPlane())[1],vector2D[1]);
mapCoordinates(((Vector3D&)someRect3D.firstPlane())[2],vector2D[2]);
mapCoordinates(((Vector3D&)someRect3D.firstPlane())[3],vector2D[3]);
DIBitmap::fillRect(vector2D,paletteIndex);
}
// line(((Vector3D&)(someRect3D.firstPlane()))[0],((Vector3D&)(someRect3D.firstPlane()))[1],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[1],((Vector3D&)(someRect3D.firstPlane()))[2],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[2],((Vector3D&)(someRect3D.firstPlane()))[3],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[3],((Vector3D&)(someRect3D.firstPlane()))[0],paletteIndex);
// line(((Vector3D&)(someRect3D.nextPlane()))[0],((Vector3D&)(someRect3D.nextPlane()))[1],paletteIndex);
// line(((Vector3D&)(someRect3D.nextPlane()))[1],((Vector3D&)(someRect3D.nextPlane()))[2],paletteIndex);
// line(((Vector3D&)(someRect3D.nextPlane()))[2],((Vector3D&)(someRect3D.nextPlane()))[3],paletteIndex);
// line(((Vector3D&)(someRect3D.nextPlane()))[3],((Vector3D&)(someRect3D.nextPlane()))[0],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[0],((Vector3D&)(someRect3D.nextPlane()))[0],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[1],((Vector3D&)(someRect3D.nextPlane()))[1],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[2],((Vector3D&)(someRect3D.nextPlane()))[2],paletteIndex);
// line(((Vector3D&)(someRect3D.firstPlane()))[3],((Vector3D&)(someRect3D.nextPlane()))[3],paletteIndex);
//}
#include <engine/angle3d.hpp>
#include <engine/angle.hpp>
Texture::Texture(const Triangle3D &angle3D,Bitmap &textureBitmap,DIBitmap &displayBitmap,Device3D &displayDevice)
: mEdgeMap(&mLeftEdge,&mRightEdge)
{
Triangle angle2D;
displayDevice.mapCoordinates((Triangle3D&)angle3D,angle2D);
mDstPoints2D[0]=angle2D[0];
mDstPoints2D[1]=angle2D[1];
mDstPoints2D[2]=angle2D[2];
mLeftEdge.numVertexes(Triangle::VectorPoints);
mRightEdge.numVertexes(Triangle::VectorPoints);
mTexturePoints[0]=Point(0,0);
mTexturePoints[1]=Point(textureBitmap.width()-1,0);
mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1);
// mLeftEdge.numVertexes(Vector3D::VectorPoints);
// mRightEdge.numVertexes(Vector3D::VectorPoints);
// mTexturePoints[0]=Point(0,0);
// mTexturePoints[1]=Point(textureBitmap.width()-1,0);
// mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1);
// mTexturePoints[3]=Point(0,textureBitmap.height()-1);
mLeftEdge.setSrcPoints((Point*)&mTexturePoints);
mLeftEdge.setDstPoints((Point*)&mDstPoints2D);
mRightEdge.setSrcPoints((Point*)&mTexturePoints);
mRightEdge.setDstPoints((Point*)&mDstPoints2D);
::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr());
::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),(unsigned char*)displayBitmap.ptrData());
}