home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
573
/
3dlab101
/
txtmap.int
< prev
next >
Wrap
Text File
|
1994-05-27
|
6KB
|
175 lines
{────────────────────────────────────────────────────────────────────────────}
{───Texture-mapping & rotation + perspektive-projektion procedures.──────────}
{────────────────────────────────────────────────────────────────────────────}
{───( C ) Copyright 1994 By Kimmo Fredriksson.───────────────────────────────}
{────────────────────────────────────────────────────────────────────────────}
{$A+ Word Alignment }
{$B- Short-circuit Boolean expression evaluation }
{$D- Debug information off }
{$E- Disable 80x87 run-time library }
{$F- Force Far Calls off }
{$G+ 80286 instructions }
{$I- I/O checking off }
{$L- Local Symbols off }
{$N- Calc reals by software }
{$O- Overlays not allowed }
{$P- Open string parameters disabled }
{$Q- Overflow Check off }
{$R- Range-checking off }
{$S- Stack-checking off }
{$T- Type-Check pointers off }
{$V- Strict Var-String off }
{$X+ Extended Syntax on }
UNIT TxtMap;
{$DEFINE DirtyDraw} { Copy only the parts that changed }
{$DEFINE ASMProcs} { Use assembler or pascal... }
INTERFACE
CONST Copyright = '(C) 1994 By Kimmo Fredriksson';
MaxPoints = 1024; { 3D-worlds co'ordinate points }
MaxTxtObjs = 1024; { TxtObj are the objects that make the world }
MaxTextures = 32; { max. amount of textures }
MaxWalls = 128; { hidden face removal help walls }
WW = 128; { Wall texture width (in pixels) }
HW = 128; { Wall texture height (in pixels) }
WWS = 7; { 2^WWS = WW ... }
HWS = 7; { 2^HWS = HW ... }
WC = 48; { width of creature (in pixeleissä) }
HC = 64; { height of... (in pixeleissä) }
HCS = 6; { 2^HCS = HC ... }
WorldXZ = 64; { Wall width and height in }
WorldY = WorldXZ; { world co'ordinates }
RemoveHFF : Boolean = TRUE; { Remove Hidden Front Face }
VScrXMax = 256; { Screen window max x }
VScrYMax = 128; { Screen window max y }
PScrXMax = 320; { Physical screen max x }
PScrYMax = 200; { Physical screen max y }
VXCent = VScrXMax DIV 2;
VYCent = VScrYMax DIV 2;
PXCent = PScrXMax DIV 2;
PYCent = PScrYMax DIV 2;
XAdj = ( PScrXMax - VScrXMax ) DIV 2; { Adjust window to screen }
YAdj = ( PScrYMax - VScrYMax ) DIV 2; { Adjust window to screen }
WOAdj = YAdj * PScrXMax + XAdj;
FarAway = ( 25 * WorldXZ ) * ( 25 * WorldXZ );
VeryClose = WorldXZ * WorldXZ;
CeilC : Byte = 64 * 2 + 48;
FloorC : Byte = 64 * 3 + 16;
TxtObj = 0; { object types }
Creature = 1;
Worm = 2;
NumOfTxtObjs : Integer = 0; { number on texture objects... }
NumOfVisTxtObjs : Integer = 0; { ...that many are visible }
NumOfWalls : Integer = 0; { used to hidden face removal... }
NumOfVisWalls : Integer = 0; { how many, and how many visible }
NumOfPoints : Integer = 0; { number of points (really) }
NumOfTxts : Integer = 0; { number of textures }
NormX : Integer = 0;
NormZ : Integer = 0;
{$I SinCos.INC} { sin&cos tables, saved as 16-bit integer, }
{ 8-bit fixed point }
TYPE TextPtr = ^Byte;
Textures = ARRAY[ 0..MaxTextures - 1 ] OF TextPtr;
VirtScrTYPE = ARRAY[ 0..VScrYMax - 1, 0..VScrXMax - 1 ] OF Byte;
VirtScrPtr = ^VirtScrTYPE; { we draw to system memory, and }
{ then copy the finished picture }
{ to video memory }
TxtObjTYPE = RECORD
Distance : LongInt; { distance to 'eye' }
LPInd : Word; { indexies to }
RPInd : Word; { point-tables }
TxtInd : Byte; { texture-index }
ObjType : Byte; { objects type }
Special : Integer; { could be used to }
END; { anything }
WallTYPE = RECORD
Distance : LongInt;
LPInd : Word;
RPInd : Word;
END;
TxtObjPtr = ^TxtObjTYPE;
WallPtr = ^WallTYPE;
TxtObjARRAY = ARRAY[ 0..MaxTxtObjs - 1 ] OF TxtObjPtr;
TxtObjARRAYPtr = ^TxtObjARRAY;
WallARRAY = ARRAY[ 0..MaxWalls - 1 ] OF WallPtr;
WallARRAYPtr = ^WallARRAY;
VAR x : ARRAY[ 0..MaxPoints - 1 ] OF Integer; { projected screen- }
y : ARRAY[ 0..MaxPoints - 1 ] OF Integer; { coordinates }
dis : ARRAY[ 0..MaxPoints - 1 ] OF
RECORD
Xd : Integer; { X and Z distances from 'eye' }
Zd : Integer;
END;
Points : ARRAY[ 0..MaxPoints - 1 ] OF
RECORD
X : Integer; { coordinates in the 3D-world, }
Z : Integer { Y is constant here }
END;
EyePA : RECORD
X : Integer; { eyes position, Y is const }
Z : Integer;
XP : LongInt; { X = XP DIV 256, but: XP <> X * 256, }
ZP : LongInt; { so the position is 8-bit fixed point }
YAng : Integer; { viewing angle, 0-359 }
END;
TxtMaps : Textures;
Obj : TxtObjARRAY;
Walls : WallARRAY;
VirtScr : VirtScrPtr;
i386 : Boolean; { CPU 386 or better ? }
CONST RawData = 0; { texture's file type, }
PCXData = 1; { Raw = raw-data, PCX = PCX (RLE) file }
PROCEDURE MakeWorldPoint( VAR xn, zn : Integer );
FUNCTION LoadTexture( CONST f : STRING; TxtType, FileType : Byte ) : Integer;
FUNCTION CreateNewTxt( TxtType : Byte ) : Integer;
PROCEDURE InitLongWall( x1, x2, z1, z2 : Integer );
FUNCTION InitAnimObj( x, z : Integer; OT, TI : Byte; S : Integer ) : Integer;
PROCEDURE InitWallTxtObj( x1, x2, z1, z2 : Integer; TI : Byte );
PROCEDURE ShowWholeVirtScr;
PROCEDURE DoMove;
IMPLEMENTATION
{ You have to register to get the source of rest of the unit. }