Repository: Arsunt/TR2Main Branch: master Commit: f38bc90438e2 Files: 212 Total size: 1.8 MB Directory structure: gitextract_vwbsridj/ ├── .gitignore ├── 3dsystem/ │ ├── 3d_gen.cpp │ ├── 3d_gen.h │ ├── 3d_out.cpp │ ├── 3d_out.h │ ├── 3dinsert.cpp │ ├── 3dinsert.h │ ├── phd_math.cpp │ ├── phd_math.h │ ├── scalespr.cpp │ └── scalespr.h ├── CHANGELOG.md ├── COPYING.md ├── Doxyfile ├── README.md ├── TR2Main.cbp ├── TR2Main.cpp ├── TR2Main.rc ├── TR2_progress.txt ├── binaries/ │ ├── BAREFOOT.SFX │ └── README.md ├── configs/ │ ├── TR2Main.json │ └── textures/ │ └── texpages/ │ ├── README.md │ └── config.json ├── embedded/ │ ├── BUTTONS.JSON │ └── BUTTONS.PCX ├── game/ │ ├── bear.cpp │ ├── bear.h │ ├── bird.cpp │ ├── bird.h │ ├── boat.cpp │ ├── boat.h │ ├── box.cpp │ ├── box.h │ ├── camera.cpp │ ├── camera.h │ ├── cinema.cpp │ ├── cinema.h │ ├── collide.cpp │ ├── collide.h │ ├── control.cpp │ ├── control.h │ ├── demo.cpp │ ├── demo.h │ ├── diver.cpp │ ├── diver.h │ ├── dog.cpp │ ├── dog.h │ ├── dragon.cpp │ ├── dragon.h │ ├── draw.cpp │ ├── draw.h │ ├── eel.cpp │ ├── eel.h │ ├── effects.cpp │ ├── effects.h │ ├── enemies.cpp │ ├── enemies.h │ ├── gameflow.cpp │ ├── gameflow.h │ ├── hair.cpp │ ├── hair.h │ ├── health.cpp │ ├── health.h │ ├── inventory.cpp │ ├── inventory.h │ ├── invfunc.cpp │ ├── invfunc.h │ ├── invtext.cpp │ ├── invtext.h │ ├── items.cpp │ ├── items.h │ ├── lara.cpp │ ├── lara.h │ ├── lara1gun.cpp │ ├── lara1gun.h │ ├── lara2gun.cpp │ ├── lara2gun.h │ ├── laraclimb.cpp │ ├── laraclimb.h │ ├── larafire.cpp │ ├── larafire.h │ ├── laraflare.cpp │ ├── laraflare.h │ ├── laramisc.cpp │ ├── laramisc.h │ ├── larasurf.cpp │ ├── larasurf.h │ ├── laraswim.cpp │ ├── laraswim.h │ ├── lot.cpp │ ├── lot.h │ ├── missile.cpp │ ├── missile.h │ ├── moveblock.cpp │ ├── moveblock.h │ ├── objects.cpp │ ├── objects.h │ ├── people.cpp │ ├── people.h │ ├── pickup.cpp │ ├── pickup.h │ ├── rat.cpp │ ├── rat.h │ ├── savegame.cpp │ ├── savegame.h │ ├── setup.cpp │ ├── setup.h │ ├── shark.cpp │ ├── shark.h │ ├── skidoo.cpp │ ├── skidoo.h │ ├── sound.cpp │ ├── sound.h │ ├── sphere.cpp │ ├── sphere.h │ ├── spider.cpp │ ├── spider.h │ ├── text.cpp │ ├── text.h │ ├── traps.cpp │ ├── traps.h │ ├── wolf.cpp │ ├── wolf.h │ ├── yeti.cpp │ └── yeti.h ├── global/ │ ├── md5.c │ ├── md5.h │ ├── memmem.c │ ├── memmem.h │ ├── precompiled.h │ ├── resource.h │ ├── types.h │ └── vars.h ├── json-parser/ │ ├── LICENSE │ ├── README.md │ ├── json.c │ └── json.h ├── modding/ │ ├── background_new.cpp │ ├── background_new.h │ ├── cd_pauld.cpp │ ├── cd_pauld.h │ ├── file_utils.cpp │ ├── file_utils.h │ ├── gdi_utils.cpp │ ├── gdi_utils.h │ ├── joy_output.cpp │ ├── joy_output.h │ ├── json_utils.cpp │ ├── json_utils.h │ ├── mod_utils.cpp │ ├── mod_utils.h │ ├── pause.cpp │ ├── pause.h │ ├── psx_bar.cpp │ ├── psx_bar.h │ ├── raw_input.cpp │ ├── raw_input.h │ ├── texture_utils.cpp │ ├── texture_utils.h │ ├── xinput_ex.cpp │ └── xinput_ex.h └── specific/ ├── background.cpp ├── background.h ├── display.cpp ├── display.h ├── file.cpp ├── file.h ├── fmv.cpp ├── fmv.h ├── frontend.cpp ├── frontend.h ├── game.cpp ├── game.h ├── hwr.cpp ├── hwr.h ├── init.cpp ├── init.h ├── init_3d.cpp ├── init_3d.h ├── init_display.cpp ├── init_display.h ├── init_input.cpp ├── init_input.h ├── init_sound.cpp ├── init_sound.h ├── input.cpp ├── input.h ├── option.cpp ├── option.h ├── output.cpp ├── output.h ├── registry.cpp ├── registry.h ├── screenshot.cpp ├── screenshot.h ├── setupdlg.cpp ├── setupdlg.h ├── setupwnd.cpp ├── setupwnd.h ├── smain.cpp ├── smain.h ├── sndpc.cpp ├── sndpc.h ├── texture.cpp ├── texture.h ├── utils.cpp ├── utils.h ├── winmain.cpp ├── winmain.h ├── winvid.cpp └── winvid.h ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.exe *.dll *.lib *.exp *.gch *.layout *.depend *.cscope_file_list cscope.out obj/ bin/ doc/ ================================================ FILE: 3dsystem/3d_gen.cpp ================================================ /* * Copyright (c) 2017-2021 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #include "global/precompiled.h" #include "3dsystem/3d_gen.h" #include "3dsystem/3d_out.h" #include "3dsystem/3dinsert.h" #include "3dsystem/phd_math.h" #include "3dsystem/scalespr.h" #include "specific/hwr.h" #include "global/vars.h" // related to POLYTYPE enum static void (__cdecl *PolyDrawRoutines[])(__int16 *) = { draw_poly_gtmap, // gouraud shaded poly (texture) draw_poly_wgtmap, // gouraud shaded poly (texture + colorkey) draw_poly_gtmap_persp, // gouraud shaded poly (texture + perspective) draw_poly_wgtmap_persp, // gouraud shaded poly (texture + colorkey + perspective) draw_poly_line, // line (color) draw_poly_flat, // flat shaded poly (color) draw_poly_gouraud, // gouraud shaded poly (color) draw_poly_trans, // shadow poly (color + semitransparent) draw_scaled_spriteC // scaled sprite (texture + colorkey) }; #if defined(FEATURE_EXTENDED_LIMITS) || defined(FEATURE_VIEW_IMPROVED) SORT_ITEM SortBuffer[16000]; __int16 Info3dBuffer[480000]; #endif // defined(FEATURE_EXTENDED_LIMITS) || defined(FEATURE_VIEW_IMPROVED) #ifdef FEATURE_EXTENDED_LIMITS PHD_SPRITE PhdSpriteInfo[2048]; D3DTLVERTEX HWR_VertexBuffer[0x8000]; #endif // FEATURE_EXTENDED_LIMITS #ifdef FEATURE_VIEW_IMPROVED bool PsxFovEnabled; // view distance double ViewDistanceFactor = 6.0; // regular fog double FogBeginFactor = 1.0; double FogEndFactor = 6.0; int FogBeginDepth = DEPTHQ_START; int FogEndDepth = DEPTHQ_END; // underwater fog double WaterFogBeginFactor = 0.6; double WaterFogEndFactor = 1.0; int WaterFogBeginDepth = DEPTHQ_START; int WaterFogEndDepth = DEPTHQ_END; // fog formula int CalculateFogShade(int depth) { int fogBegin, fogEnd; if( IsWaterEffect ) { fogBegin = WaterFogBeginDepth; fogEnd = WaterFogEndDepth; } else { fogBegin = FogBeginDepth; fogEnd = FogEndDepth; } if( depth < fogBegin ) return 0; if( depth >= fogEnd ) return 0x1FFF; return (depth - fogBegin) * 0x1FFF / (fogEnd - fogBegin); } #endif // FEATURE_VIEW_IMPROVED #ifdef FEATURE_VIDEOFX_IMPROVED #include "modding/mod_utils.h" extern DWORD ReflectionMode; static POLYFILTER ReflectFilter; static D3DCOLOR ReflectTint = 0; static bool IsReflect = false; void ClearMeshReflectState() { memset(&ReflectFilter, 0 , sizeof(ReflectFilter)); ReflectTint = RGBA_MAKE(0xFF,0xFF,0xFF,0x80); IsReflect = false; } void SetMeshReflectState(int objID, int meshIdx) { // Clear poly filters and disable reflection by default ClearMeshReflectState(); if( TextureFormat.bpp < 16 || !ReflectionMode ) return; if( objID == ID_NONE ) { // Reflect all meshes with custom tint instead of mesh index ReflectTint = meshIdx; IsReflect = true; return; } #ifdef FEATURE_MOD_CONFIG // Check if config is presented if( IsModReflectConfigLoaded() ) { POLYFILTER_NODE *node = NULL; if( meshIdx < 0 ) { for( node = GetModReflectStaticsFilter(); node != NULL; node = node->next ) { if( node->id == objID ) { ReflectFilter = node->filter; IsReflect = true; break; } } } else if( objID >= 0 && objID < ID_NUMBER_OBJECTS ) { POLYFILTER_NODE **obj = GetModReflectObjectsFilter(); for( node = obj[objID]; node != NULL; node = node->next ) { if( node->id == meshIdx ) { ReflectFilter = node->filter; IsReflect = true; break; } } } return; } #endif // FEATURE_MOD_CONFIG // If config is absent or disabled, use hardcoded params if( objID >= 0 && meshIdx < 0 ) { // This is static object mesh return; } // This is animated object mesh switch( objID ) { case ID_SKIDOO_FAST : // This one is a fast showmobile from the Golden Mask // Reflect the windshield only (skidoo body is mesh #0) if( meshIdx == 0 ) { // Set filter conditions ReflectFilter.n_vtx = 59; ReflectFilter.n_gt4 = 14; ReflectFilter.n_gt3 = 73; ReflectFilter.n_g4 = 0; ReflectFilter.n_g3 = 17; // All colored triangles are reflective // The only reflective textured triangle is 48 ReflectFilter.gt3[0].idx = 48; ReflectFilter.gt3[0].num = 1; // Quads are not reflective ReflectFilter.gt4[0].idx = ~0; ReflectFilter.g4[0].idx = ~0; IsReflect = true; } break; case ID_SKIDOO_ARMED : // This one is an armed showmobile // Reflect the windshield only (skidoo body is mesh #0) if( meshIdx == 0 ) { // Set filter conditions ReflectFilter.n_vtx = 88; ReflectFilter.n_gt4 = 45; ReflectFilter.n_gt3 = 60; ReflectFilter.n_g4 = 0; ReflectFilter.n_g3 = 0; // The reflective textured quads are 21..22, 34..47 ReflectFilter.gt4[0].idx = 21; ReflectFilter.gt4[0].num = 2; ReflectFilter.gt3[0].idx = 34; ReflectFilter.gt3[0].num = 14; // Other polys are not reflective ReflectFilter.g4[0].idx = ~0; ReflectFilter.g3[0].idx = ~0; IsReflect = true; } break; case ID_WORKER5 : // Reflect the black glass mask of flamethrower buddy (his head is mesh #15) if( meshIdx == 15 ) { // Set filter conditions ReflectFilter.n_vtx = 38; ReflectFilter.n_gt4 = 30; ReflectFilter.n_gt3 = 12; ReflectFilter.n_g4 = 0; ReflectFilter.n_g3 = 0; // The reflective textured quads are 22..26 ReflectFilter.gt4[0].idx = 22; ReflectFilter.gt4[0].num = 5; // Other polys are not reflective ReflectFilter.gt3[0].idx = ~0; ReflectFilter.g4[0].idx = ~0; ReflectFilter.g3[0].idx = ~0; IsReflect = true; } break; case ID_SPINNING_BLADE : if( meshIdx == 0 ) { // Reflect only quads, not triangles ReflectFilter.gt3[0].idx = ~0; ReflectFilter.g3[0].idx = ~0; IsReflect = true; } break; case ID_BLADE : // Reflect the blade only (mesh #1) if( meshIdx == 1 ) { IsReflect = true; } break; case ID_KILLER_STATUE : // Reflect the sword only (mesh #7) if( meshIdx == 7 ) { IsReflect = true; } break; } } static bool InsertEnvmap(__int16 *ptrObj, int vtxCount, bool colored, LPVOID param) { InsertObjectEM(ptrObj, vtxCount, ReflectTint, (PHD_UV *)param); return true; } static void phd_PutEnvmapPolygons(__int16 *ptrEnv) { if( ptrEnv == NULL || !IsReflect || SavedAppSettings.RenderMode != RM_Hardware ) return; __int16 *ptrObj = ptrEnv; ptrObj += 5; // skip x, y, z, radius, flags __int16 num = *(ptrObj++); // get vertex counter ptrObj += num * 3; // skip vertices int vtxCount = *ptrObj++; if( vtxCount <= 0 ) return; PHD_UV *uv = new PHD_UV[vtxCount]; for( int i = 0; i < vtxCount; ++i ) { // make sure that reflection will be drawn after normal poly PhdVBuf[i].zv -= (double)(W2V_SCALE/2); // set lighting that depends only from fog distance PhdVBuf[i].g = 0x1000; int depth = PhdMatrixPtr->_23 >> W2V_SHIFT; #ifdef FEATURE_VIEW_IMPROVED PhdVBuf[i].g += CalculateFogShade(depth); #else // !FEATURE_VIEW_IMPROVED if( depth > DEPTHQ_START ) // fog begin PhdVBuf[i].g += depth - DEPTHQ_START; #endif // FEATURE_VIEW_IMPROVED CLAMP(PhdVBuf[i].g, 0x1000, 0x1FFF); // reflection can be darker but not brighter // rotate normal vectors for X/Y, no translation int x = (PhdMatrixPtr->_00 * ptrObj[0] + PhdMatrixPtr->_01 * ptrObj[1] + PhdMatrixPtr->_02 * ptrObj[2]) >> W2V_SHIFT; int y = (PhdMatrixPtr->_10 * ptrObj[0] + PhdMatrixPtr->_11 * ptrObj[1] + PhdMatrixPtr->_12 * ptrObj[2]) >> W2V_SHIFT; CLAMP(x, -PHD_IONE, PHD_IONE); CLAMP(y, -PHD_IONE, PHD_IONE); uv[i].u = PHD_ONE/PHD_IONE * (x + PHD_IONE)/2; uv[i].v = PHD_ONE/PHD_IONE * (y + PHD_IONE)/2; ptrObj += 3; } EnumeratePolys(ptrEnv, false, InsertEnvmap, &ReflectFilter, (LPVOID)uv); delete[] uv; } #endif // FEATURE_VIDEOFX_IMPROVED void phd_GenerateW2V(PHD_3DPOS *viewPos) { int sx = phd_sin(viewPos->rotX); int cx = phd_cos(viewPos->rotX); int sy = phd_sin(viewPos->rotY); int cy = phd_cos(viewPos->rotY); int sz = phd_sin(viewPos->rotZ); int cz = phd_cos(viewPos->rotZ); PhdMatrixPtr = &MatrixStack[0]; // set matrix stack pointer to W2V MatrixW2V._00 = PhdMatrixPtr->_00 = TRIGMULT3(sx, sy, sz) + TRIGMULT2(cy, cz); MatrixW2V._01 = PhdMatrixPtr->_01 = TRIGMULT2(cx, sz); MatrixW2V._02 = PhdMatrixPtr->_02 = TRIGMULT3(sx, cy, sz) - TRIGMULT2(sy, cz); MatrixW2V._10 = PhdMatrixPtr->_10 = (int)(FltViewAspect * (double)(TRIGMULT3(sx, sy, cz) - TRIGMULT2(cy, sz))); MatrixW2V._11 = PhdMatrixPtr->_11 = (int)(FltViewAspect * (double)(TRIGMULT2(cx, cz))); MatrixW2V._12 = PhdMatrixPtr->_12 = (int)(FltViewAspect * (double)(TRIGMULT3(sx, cy, cz) + TRIGMULT2(sy, sz))); MatrixW2V._20 = PhdMatrixPtr->_20 = TRIGMULT2(cx, sy); MatrixW2V._21 = PhdMatrixPtr->_21 = -(sx); MatrixW2V._22 = PhdMatrixPtr->_22 = TRIGMULT2(cx, cy); MatrixW2V._03 = PhdMatrixPtr->_03 = viewPos->x;; MatrixW2V._13 = PhdMatrixPtr->_13 = viewPos->y; MatrixW2V._23 = PhdMatrixPtr->_23 = viewPos->z; } void __cdecl phd_LookAt(int xsrc, int ysrc, int zsrc, int xtar, int ytar, int ztar, __int16 roll) { PHD_3DPOS viewPos; VECTOR_ANGLES angles; phd_GetVectorAngles(xtar - xsrc, ytar - ysrc, ztar - zsrc, &angles); viewPos.x = xsrc; viewPos.y = ysrc; viewPos.z = zsrc; viewPos.rotX = angles.pitch; viewPos.rotY = angles.yaw; viewPos.rotZ = roll; phd_GenerateW2V(&viewPos); } void __cdecl phd_GetVectorAngles(int x, int y, int z, VECTOR_ANGLES *angles) { __int16 pitch; angles->yaw = phd_atan(z, x); while( (__int16)x != x || (__int16)y != y || (__int16)z != z ) { x >>= 2; y >>= 2; z >>= 2; } pitch = phd_atan(phd_sqrt(SQR(x) + SQR(z)), y); if( (y > 0 && pitch > 0) || (y < 0 && pitch < 0) ) pitch = -pitch; angles->pitch = pitch; } void __cdecl phd_RotX(__int16 angle) { if( angle != 0 ) { int m0, m1; int sx = phd_sin(angle); int cx = phd_cos(angle); m0 = PhdMatrixPtr->_01 * cx + PhdMatrixPtr->_02 * sx; m1 = PhdMatrixPtr->_02 * cx - PhdMatrixPtr->_01 * sx; PhdMatrixPtr->_01 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_11 * cx + PhdMatrixPtr->_12 * sx; m1 = PhdMatrixPtr->_12 * cx - PhdMatrixPtr->_11 * sx; PhdMatrixPtr->_11 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_21 * cx + PhdMatrixPtr->_22 * sx; m1 = PhdMatrixPtr->_22 * cx - PhdMatrixPtr->_21 * sx; PhdMatrixPtr->_21 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } } void __cdecl phd_RotY(__int16 angle) { if( angle != 0 ) { int m0, m1; int sy = phd_sin(angle); int cy = phd_cos(angle); m0 = PhdMatrixPtr->_00 * cy - PhdMatrixPtr->_02 * sy; m1 = PhdMatrixPtr->_02 * cy + PhdMatrixPtr->_00 * sy; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cy - PhdMatrixPtr->_12 * sy; m1 = PhdMatrixPtr->_12 * cy + PhdMatrixPtr->_10 * sy; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cy - PhdMatrixPtr->_22 * sy; m1 = PhdMatrixPtr->_22 * cy + PhdMatrixPtr->_20 * sy; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } } void __cdecl phd_RotZ(__int16 angle) { if( angle != 0 ) { int m0, m1; int sz = phd_sin(angle); int cz = phd_cos(angle); m0 = PhdMatrixPtr->_00 * cz + PhdMatrixPtr->_01 * sz; m1 = PhdMatrixPtr->_01 * cz - PhdMatrixPtr->_00 * sz; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_01 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cz + PhdMatrixPtr->_11 * sz; m1 = PhdMatrixPtr->_11 * cz - PhdMatrixPtr->_10 * sz; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_11 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cz + PhdMatrixPtr->_21 * sz; m1 = PhdMatrixPtr->_21 * cz - PhdMatrixPtr->_20 * sz; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_21 = m1 >> W2V_SHIFT; } } void __cdecl phd_RotYXZ(__int16 ry, __int16 rx, __int16 rz) { int sx, cx; int sy, cy; int sz, cz; int m0, m1; if( ry != 0 ) { sy = phd_sin(ry); cy = phd_cos(ry); m0 = PhdMatrixPtr->_00 * cy - PhdMatrixPtr->_02 * sy; m1 = PhdMatrixPtr->_02 * cy + PhdMatrixPtr->_00 * sy; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cy - PhdMatrixPtr->_12 * sy; m1 = PhdMatrixPtr->_12 * cy + PhdMatrixPtr->_10 * sy; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cy - PhdMatrixPtr->_22 * sy; m1 = PhdMatrixPtr->_22 * cy + PhdMatrixPtr->_20 * sy; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } if( rx != 0 ) { sx = phd_sin(rx); cx = phd_cos(rx); m0 = PhdMatrixPtr->_01 * cx + PhdMatrixPtr->_02 * sx; m1 = PhdMatrixPtr->_02 * cx - PhdMatrixPtr->_01 * sx; PhdMatrixPtr->_01 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_11 * cx + PhdMatrixPtr->_12 * sx; m1 = PhdMatrixPtr->_12 * cx - PhdMatrixPtr->_11 * sx; PhdMatrixPtr->_11 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_21 * cx + PhdMatrixPtr->_22 * sx; m1 = PhdMatrixPtr->_22 * cx - PhdMatrixPtr->_21 * sx; PhdMatrixPtr->_21 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } if( rz != 0 ) { sz = phd_sin(rz); cz = phd_cos(rz); m0 = PhdMatrixPtr->_00 * cz + PhdMatrixPtr->_01 * sz; m1 = PhdMatrixPtr->_01 * cz - PhdMatrixPtr->_00 * sz; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_01 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cz + PhdMatrixPtr->_11 * sz; m1 = PhdMatrixPtr->_11 * cz - PhdMatrixPtr->_10 * sz; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_11 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cz + PhdMatrixPtr->_21 * sz; m1 = PhdMatrixPtr->_21 * cz - PhdMatrixPtr->_20 * sz; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_21 = m1 >> W2V_SHIFT; } } void __cdecl phd_RotYXZpack(DWORD rpack) { int sx, cx; int sy, cy; int sz, cz; int m0, m1; __int16 rx = ((rpack >> 20) & 0x3FF) << 6; __int16 ry = ((rpack >> 10) & 0x3FF) << 6; __int16 rz = ((rpack >> 00) & 0x3FF) << 6; if( ry != 0 ) { sy = phd_sin(ry); cy = phd_cos(ry); m0 = PhdMatrixPtr->_00 * cy - PhdMatrixPtr->_02 * sy; m1 = PhdMatrixPtr->_02 * cy + PhdMatrixPtr->_00 * sy; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cy - PhdMatrixPtr->_12 * sy; m1 = PhdMatrixPtr->_12 * cy + PhdMatrixPtr->_10 * sy; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cy - PhdMatrixPtr->_22 * sy; m1 = PhdMatrixPtr->_22 * cy + PhdMatrixPtr->_20 * sy; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } if( rx != 0 ) { sx = phd_sin(rx); cx = phd_cos(rx); m0 = PhdMatrixPtr->_01 * cx + PhdMatrixPtr->_02 * sx; m1 = PhdMatrixPtr->_02 * cx - PhdMatrixPtr->_01 * sx; PhdMatrixPtr->_01 = m0 >> W2V_SHIFT; PhdMatrixPtr->_02 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_11 * cx + PhdMatrixPtr->_12 * sx; m1 = PhdMatrixPtr->_12 * cx - PhdMatrixPtr->_11 * sx; PhdMatrixPtr->_11 = m0 >> W2V_SHIFT; PhdMatrixPtr->_12 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_21 * cx + PhdMatrixPtr->_22 * sx; m1 = PhdMatrixPtr->_22 * cx - PhdMatrixPtr->_21 * sx; PhdMatrixPtr->_21 = m0 >> W2V_SHIFT; PhdMatrixPtr->_22 = m1 >> W2V_SHIFT; } if( rz != 0 ) { sz = phd_sin(rz); cz = phd_cos(rz); m0 = PhdMatrixPtr->_00 * cz + PhdMatrixPtr->_01 * sz; m1 = PhdMatrixPtr->_01 * cz - PhdMatrixPtr->_00 * sz; PhdMatrixPtr->_00 = m0 >> W2V_SHIFT; PhdMatrixPtr->_01 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_10 * cz + PhdMatrixPtr->_11 * sz; m1 = PhdMatrixPtr->_11 * cz - PhdMatrixPtr->_10 * sz; PhdMatrixPtr->_10 = m0 >> W2V_SHIFT; PhdMatrixPtr->_11 = m1 >> W2V_SHIFT; m0 = PhdMatrixPtr->_20 * cz + PhdMatrixPtr->_21 * sz; m1 = PhdMatrixPtr->_21 * cz - PhdMatrixPtr->_20 * sz; PhdMatrixPtr->_20 = m0 >> W2V_SHIFT; PhdMatrixPtr->_21 = m1 >> W2V_SHIFT; } } BOOL __cdecl phd_TranslateRel(int x, int y, int z) { PhdMatrixPtr->_03 += PhdMatrixPtr->_00 * x + PhdMatrixPtr->_01 * y + PhdMatrixPtr->_02 * z; PhdMatrixPtr->_13 += PhdMatrixPtr->_10 * x + PhdMatrixPtr->_11 * y + PhdMatrixPtr->_12 * z; PhdMatrixPtr->_23 += PhdMatrixPtr->_20 * x + PhdMatrixPtr->_21 * y + PhdMatrixPtr->_22 * z; if( ABS(PhdMatrixPtr->_03) > PhdFarZ || ABS(PhdMatrixPtr->_13) > PhdFarZ || ABS(PhdMatrixPtr->_23) > PhdFarZ ) { return FALSE; } return TRUE; } void __cdecl phd_TranslateAbs(int x, int y, int z) { x -= MatrixW2V._03; y -= MatrixW2V._13; z -= MatrixW2V._23; PhdMatrixPtr->_03 = x * PhdMatrixPtr->_00 + y * PhdMatrixPtr->_01 + z * PhdMatrixPtr->_02; PhdMatrixPtr->_13 = x * PhdMatrixPtr->_10 + y * PhdMatrixPtr->_11 + z * PhdMatrixPtr->_12; PhdMatrixPtr->_23 = x * PhdMatrixPtr->_20 + y * PhdMatrixPtr->_21 + z * PhdMatrixPtr->_22; } void __cdecl phd_PutPolygons(__int16 *ptrObj, int clip) { FltWinLeft = (float)PhdWinMinX; FltWinTop = (float)PhdWinMinY; FltWinRight = (float)(PhdWinMinX + PhdWinMaxX + 1); FltWinBottom = (float)(PhdWinMinY + PhdWinMaxY + 1); FltWinCenterX = (float)(PhdWinMinX + PhdWinCenterX); FltWinCenterY = (float)(PhdWinMinY + PhdWinCenterY); #ifdef FEATURE_VIDEOFX_IMPROVED __int16 *ptrEnv = ptrObj; #endif // FEATURE_VIDEOFX_IMPROVED ptrObj += 4; // skip x, y, z, radius ptrObj = calc_object_vertices(ptrObj); if( ptrObj != NULL ) { ptrObj = calc_vertice_light(ptrObj); ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_AvgZ); ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_AvgZ); ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_AvgZ); ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_AvgZ); #ifdef FEATURE_VIDEOFX_IMPROVED phd_PutEnvmapPolygons(ptrEnv); #endif // FEATURE_VIDEOFX_IMPROVED } } void __cdecl S_InsertRoom(__int16 *ptrObj, BOOL isOutside) { FltWinLeft = (float)(PhdWinMinX + PhdWinLeft); FltWinTop = (float)(PhdWinMinY + PhdWinTop); FltWinRight = (float)(PhdWinMinX + PhdWinRight + 1); FltWinBottom = (float)(PhdWinMinY + PhdWinBottom + 1); FltWinCenterX = (float)(PhdWinMinX + PhdWinCenterX); FltWinCenterY = (float)(PhdWinMinY + PhdWinCenterY); ptrObj = calc_roomvert(ptrObj, isOutside?0x00:0x10); ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_MaxZ); ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_MaxZ); ptrObj = ins_room_sprite(ptrObj+1, *ptrObj); } __int16 *__cdecl calc_background_light(__int16 *ptrObj) { int vtxCount = *ptrObj++; if( vtxCount > 0 ) { ptrObj += 3 * vtxCount; } else if( vtxCount < 0 ) { vtxCount = -vtxCount; ptrObj += vtxCount; } // Skybox has normal brightness int shade = 0x0FFF; // NOTE: Sunset did not change the skybox brightness in the original game if( GF_SunsetEnabled ) shade += 0x400 * SunsetTimer / SUNSET_TIMEOUT; for( int i = 0; i < vtxCount; ++i ) PhdVBuf[i].g = shade; return ptrObj; } void __cdecl S_InsertBackground(__int16 *ptrObj) { FltWinLeft = (float)(PhdWinMinX + PhdWinLeft); FltWinTop = (float)(PhdWinMinY + PhdWinTop); FltWinRight = (float)(PhdWinMinX + PhdWinRight + 1); FltWinBottom = (float)(PhdWinMinY + PhdWinBottom + 1); FltWinCenterX = (float)(PhdWinMinX + PhdWinCenterX); FltWinCenterY = (float)(PhdWinMinY + PhdWinCenterY); ptrObj += 4; // skip x, y, z, radius ptrObj = calc_object_vertices(ptrObj); if( ptrObj == NULL ) { return; } ptrObj = calc_background_light(ptrObj); #ifdef FEATURE_VIEW_IMPROVED MidSort = 0xFFFF; #endif // FEATURE_VIEW_IMPROVED if( SavedAppSettings.RenderMode == RM_Hardware ) { HWR_EnableZBuffer(false, false); } ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_FarZ); ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_FarZ); ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_FarZ); ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_FarZ); if( SavedAppSettings.RenderMode == RM_Hardware ) { HWR_EnableZBuffer(true, true); } #ifdef FEATURE_VIEW_IMPROVED MidSort = 0; #endif // FEATURE_VIEW_IMPROVED } void __cdecl S_InsertInvBgnd(__int16 *ptrObj) { // NOTE: Null function in the PC version. // But there is waving inventory function in the PlayStation version. // Main S_InsertInvBgnd() logic is similar to S_InsertBackground(); } __int16 *__cdecl calc_object_vertices(__int16 *ptrObj) { double xv, yv, zv, persp, baseZ; int vtxCount; BYTE totalClip, clipFlags; baseZ = 0.0; #ifndef FEATURE_VIEW_IMPROVED if( SavedAppSettings.RenderMode == RM_Software || !SavedAppSettings.ZBuffer ) { baseZ = (double)(MidSort << (W2V_SHIFT + 8)); } #endif // !FEATURE_VIEW_IMPROVED totalClip = 0xFF; ptrObj++; // skip poly counter vtxCount = *(ptrObj++); // get vertex counter if( vtxCount < 0 ) { printf("vtxCount=%d", vtxCount); } for( int i = 0; i < vtxCount; ++i ) { xv = (double)(PhdMatrixPtr->_00 * ptrObj[0] + PhdMatrixPtr->_01 * ptrObj[1] + PhdMatrixPtr->_02 * ptrObj[2] + PhdMatrixPtr->_03); yv = (double)(PhdMatrixPtr->_10 * ptrObj[0] + PhdMatrixPtr->_11 * ptrObj[1] + PhdMatrixPtr->_12 * ptrObj[2] + PhdMatrixPtr->_13); zv = (double)(PhdMatrixPtr->_20 * ptrObj[0] + PhdMatrixPtr->_21 * ptrObj[1] + PhdMatrixPtr->_22 * ptrObj[2] + PhdMatrixPtr->_23); PhdVBuf[i].xv = xv; PhdVBuf[i].yv = yv; if( zv < FltNearZ ) { clipFlags = 0x80; PhdVBuf[i].zv = zv; } else { clipFlags = 0; if( zv >= FltFarZ ) { zv = FltFarZ; PhdVBuf[i].zv = zv; } else { PhdVBuf[i].zv = zv + baseZ; } persp = FltPersp / zv; PhdVBuf[i].xs = persp * xv + FltWinCenterX; PhdVBuf[i].ys = persp * yv + FltWinCenterY; PhdVBuf[i].rhw = persp * FltRhwOPersp; if( PhdVBuf[i].xs < FltWinLeft ) clipFlags |= 0x01; else if( PhdVBuf[i].xs > FltWinRight ) clipFlags |= 0x02; if( PhdVBuf[i].ys < FltWinTop ) clipFlags |= 0x04; else if( PhdVBuf[i].ys > FltWinBottom ) clipFlags |= 0x08; } PhdVBuf[i].clip = clipFlags; totalClip &= clipFlags; ptrObj += 3; } return ( totalClip == 0 ) ? ptrObj : NULL; } __int16 *__cdecl calc_vertice_light(__int16 *ptrObj) { int i, xv, yv, zv; __int16 shade; int vtxCount = *ptrObj++; if( vtxCount > 0 ) { if( LsDivider != 0 ) { xv = (PhdMatrixPtr->_00 * LsVectorView.x + PhdMatrixPtr->_10 * LsVectorView.y + PhdMatrixPtr->_20 * LsVectorView.z) / LsDivider; yv = (PhdMatrixPtr->_01 * LsVectorView.x + PhdMatrixPtr->_11 * LsVectorView.y + PhdMatrixPtr->_21 * LsVectorView.z) / LsDivider; zv = (PhdMatrixPtr->_02 * LsVectorView.x + PhdMatrixPtr->_12 * LsVectorView.y + PhdMatrixPtr->_22 * LsVectorView.z) / LsDivider; for( i = 0; i < vtxCount; ++i ) { shade = LsAdder + ((ptrObj[0]*xv + ptrObj[1]*yv + ptrObj[2]*zv) >> 16); CLAMP(shade, 0, 0x1FFF); PhdVBuf[i].g = shade; ptrObj += 3; } } else { shade = LsAdder; CLAMP(shade, 0, 0x1FFF); for( i = 0; i < vtxCount; ++i ) { PhdVBuf[i].g = shade; } ptrObj += 3*vtxCount; } } else { for( i = 0; i < -vtxCount; ++i ) { shade = LsAdder + *ptrObj; CLAMP(shade, 0, 0x1FFF); PhdVBuf[i].g = shade; ++ptrObj; } } return ptrObj; } __int16 *__cdecl calc_roomvert(__int16 *ptrObj, BYTE farClip) { double xv, yv, zv, persp, baseZ, depth; int vtxCount, zv_int; baseZ = 0.0; #ifndef FEATURE_VIEW_IMPROVED if( SavedAppSettings.RenderMode == RM_Software || !SavedAppSettings.ZBuffer ) { baseZ = (double)(MidSort << (W2V_SHIFT + 8)); } #endif // !FEATURE_VIEW_IMPROVED vtxCount = *(ptrObj++); for( int i = 0; i < vtxCount; ++i ) { xv = (double)(PhdMatrixPtr->_00 * ptrObj[0] + PhdMatrixPtr->_01 * ptrObj[1] + PhdMatrixPtr->_02 * ptrObj[2] + PhdMatrixPtr->_03); yv = (double)(PhdMatrixPtr->_10 * ptrObj[0] + PhdMatrixPtr->_11 * ptrObj[1] + PhdMatrixPtr->_12 * ptrObj[2] + PhdMatrixPtr->_13); zv_int = (PhdMatrixPtr->_20 * ptrObj[0] + PhdMatrixPtr->_21 * ptrObj[1] + PhdMatrixPtr->_22 * ptrObj[2] + PhdMatrixPtr->_23); zv = (double)zv_int; PhdVBuf[i].xv = xv; PhdVBuf[i].yv = yv; PhdVBuf[i].g = ptrObj[5]; if( IsWaterEffect != 0 ) PhdVBuf[i].g += ShadesTable[(WibbleOffset + (BYTE)RandomTable[(vtxCount - i) % WIBBLE_SIZE]) % WIBBLE_SIZE]; if( zv < FltNearZ ) { PhdVBuf[i].clip = 0xFF80; PhdVBuf[i].zv = zv; } else { persp = FltPersp / zv; depth = zv_int >> W2V_SHIFT; #ifdef FEATURE_VIEW_IMPROVED if( depth >= PhdViewDistance ) { PhdVBuf[i].rhw = persp * FltRhwOPersp; PhdVBuf[i].zv = zv + baseZ; #else // !FEATURE_VIEW_IMPROVED if( depth >= DEPTHQ_END ) { // fog end PhdVBuf[i].rhw = 0.0; // NOTE: zero RHW is an invalid value, but the original game sets it. PhdVBuf[i].zv = FltFarZ; #endif // FEATURE_VIEW_IMPROVED PhdVBuf[i].g = 0x1FFF; PhdVBuf[i].clip = farClip; } else { #ifdef FEATURE_VIEW_IMPROVED PhdVBuf[i].g += CalculateFogShade(depth); #else // !FEATURE_VIEW_IMPROVED if( depth > DEPTHQ_START ) { // fog begin PhdVBuf[i].g += depth - DEPTHQ_START; } #endif // FEATURE_VIEW_IMPROVED PhdVBuf[i].rhw = persp * FltRhwOPersp; PhdVBuf[i].clip = 0; PhdVBuf[i].zv = zv + baseZ; } PhdVBuf[i].xs = persp * xv + FltWinCenterX; PhdVBuf[i].ys = persp * yv + FltWinCenterY; if( IsWibbleEffect && ptrObj[4] >= 0 ) { PhdVBuf[i].xs += WibbleTable[(WibbleOffset + (BYTE)PhdVBuf[i].ys) % WIBBLE_SIZE]; PhdVBuf[i].ys += WibbleTable[(WibbleOffset + (BYTE)PhdVBuf[i].xs) % WIBBLE_SIZE]; } if( PhdVBuf[i].xs < FltWinLeft ) PhdVBuf[i].clip |= 0x01; else if( PhdVBuf[i].xs > FltWinRight ) PhdVBuf[i].clip |= 0x02; if( PhdVBuf[i].ys < FltWinTop ) PhdVBuf[i].clip |= 0x04; else if( PhdVBuf[i].ys > FltWinBottom ) PhdVBuf[i].clip |= 0x08; PhdVBuf[i].clip |= ~(BYTE)(PhdVBuf[i].zv / 0x155555.p0) << 8; } CLAMP(PhdVBuf[i].g, 0, 0x1FFF); ptrObj += 6; } return ptrObj; } void __cdecl phd_RotateLight(__int16 pitch, __int16 yaw) { int xcos, ysin, wcos, wsin; int ls_x, ls_y, ls_z; PhdLsYaw = yaw; PhdLsPitch = pitch; xcos = phd_cos(pitch); ysin = phd_sin(pitch); wcos = phd_cos(yaw); wsin = phd_sin(yaw); ls_x = TRIGMULT2(xcos, wsin); ls_y = -ysin; ls_z = TRIGMULT2(xcos, wcos); LsVectorView.x = (MatrixW2V._00 * ls_x + MatrixW2V._01 * ls_y + MatrixW2V._02 * ls_z) >> W2V_SHIFT; LsVectorView.y = (MatrixW2V._10 * ls_x + MatrixW2V._11 * ls_y + MatrixW2V._12 * ls_z) >> W2V_SHIFT; LsVectorView.z = (MatrixW2V._20 * ls_x + MatrixW2V._21 * ls_y + MatrixW2V._22 * ls_z) >> W2V_SHIFT; } void __cdecl phd_InitPolyList() { SurfaceCount = 0; Sort3dPtr = SortBuffer; Info3dPtr = Info3dBuffer; if( SavedAppSettings.RenderMode == RM_Hardware ) HWR_VertexPtr = HWR_VertexBuffer; } void __cdecl phd_SortPolyList() { if( SurfaceCount ) { for( DWORD i=0; i compare) ) ++i; while( (left < j) && (compare > SortBuffer[j]._1) ) --j; if( i > j ) break; SWAP(SortBuffer[i]._0, SortBuffer[j]._0, swapBuf); SWAP(SortBuffer[i]._1, SortBuffer[j]._1, swapBuf); } while( ++i <= --j ); if( left < j ) do_quickysorty(left, j); if( i < right ) do_quickysorty(i, right); } void __cdecl phd_PrintPolyList(BYTE *surfacePtr) { __int16 polyType, *bufPtr; PrintSurfacePtr = surfacePtr; for( DWORD i=0; i_00 = W2V_SCALE; PhdMatrixPtr->_11 = W2V_SCALE; PhdMatrixPtr->_22 = W2V_SCALE; } /* * Inject function */ void Inject_3Dgen() { INJECT(0x00401000, phd_GenerateW2V); INJECT(0x004011D0, phd_LookAt); INJECT(0x00401250, phd_GetVectorAngles); INJECT(0x004012D0, phd_RotX); INJECT(0x00401380, phd_RotY); INJECT(0x00401430, phd_RotZ); INJECT(0x004014E0, phd_RotYXZ); INJECT(0x004016C0, phd_RotYXZpack); INJECT(0x004018B0, phd_TranslateRel); INJECT(0x00401960, phd_TranslateAbs); INJECT(0x004019E0, phd_PutPolygons); INJECT(0x00401AE0, S_InsertRoom); INJECT(0x00401BD0, calc_background_light); INJECT(0x00401C10, S_InsertBackground); // INJECT(----------, S_InsertInvBgnd); // NOTE: this is null in the original code INJECT(0x00401D50, calc_object_vertices); INJECT(0x00401F30, calc_vertice_light); INJECT(0x004020A0, calc_roomvert); INJECT(0x00402320, phd_RotateLight); INJECT(0x004023F0, phd_InitPolyList); INJECT(0x00402420, phd_SortPolyList); INJECT(0x00402460, do_quickysorty); INJECT(0x00402530, phd_PrintPolyList); INJECT(0x00402570, AlterFOV); INJECT(0x00402680, phd_SetNearZ); INJECT(0x004026D0, phd_SetFarZ); INJECT(0x004026F0, phd_InitWindow); // INJECT(----------, phd_PopMatrix); // NOTE: this is inline or macro in the original code INJECT(0x00457510, phd_PushMatrix); INJECT(0x0045752E, phd_PushUnitMatrix); } ================================================ FILE: 3dsystem/3d_gen.h ================================================ /* * Copyright (c) 2017-2020 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #ifndef _3DGEN_H_INCLUDED #define _3DGEN_H_INCLUDED #include "global/types.h" /* * Function list */ #ifdef FEATURE_VIDEOFX_IMPROVED void ClearMeshReflectState(); void SetMeshReflectState(int objID, int meshIdx); #endif // FEATURE_VIDEOFX_IMPROVED void phd_GenerateW2V(PHD_3DPOS *viewPos); // 0x00401000 void __cdecl phd_LookAt(int xsrc, int ysrc, int zsrc, int xtar, int ytar, int ztar, __int16 roll); // 0x004011D0 void __cdecl phd_GetVectorAngles(int x, int y, int z, VECTOR_ANGLES *angles); // 0x00401250 void __cdecl phd_RotX(__int16 angle); // 0x004012D0 void __cdecl phd_RotY(__int16 angle); // 0x00401380 void __cdecl phd_RotZ(__int16 angle); // 0x00401430 void __cdecl phd_RotYXZ(__int16 ry, __int16 rx, __int16 rz); // 0x004014E0 void __cdecl phd_RotYXZpack(DWORD rpack); // 0x004016C0 BOOL __cdecl phd_TranslateRel(int x, int y, int z); // 0x004018B0 void __cdecl phd_TranslateAbs(int x, int y, int z); // 0x00401960 void __cdecl phd_PutPolygons(__int16 *ptrObj, int clip); // 0x004019E0 void __cdecl S_InsertRoom(__int16 *ptrObj, BOOL isOutside); // 0x00401AE0 __int16 *__cdecl calc_background_light(__int16 *ptrObj); // 0x00401BD0 void __cdecl S_InsertBackground(__int16 *ptrObj); // 0x00401C10 void __cdecl S_InsertInvBgnd(__int16 *ptrObj); // ---------- __int16 *__cdecl calc_object_vertices(__int16 *ptrObj); // 0x00401D50 __int16 *__cdecl calc_vertice_light(__int16 *ptrObj); // 0x00401F30 __int16 *__cdecl calc_roomvert(__int16 *ptrObj, BYTE farClip); // 0x004020A0 void __cdecl phd_RotateLight(__int16 pitch, __int16 yaw); // 0x00402320 void __cdecl phd_InitPolyList(); // 0x004023F0 void __cdecl phd_SortPolyList(); // 0x00402420 void __cdecl do_quickysorty(int left, int right); // 0x00402460 void __cdecl phd_PrintPolyList(BYTE *surfacePtr); // 0x00402530 void __cdecl AlterFOV(__int16 fov); // 0x00402570 void __cdecl phd_SetNearZ(int nearZ); // 0x00402680 void __cdecl phd_SetFarZ(int farZ); // 0x004026D0 void __cdecl phd_InitWindow(__int16 x, __int16 y, int width, int height, int nearZ, int farZ, __int16 viewAngle, int screenWidth, int screenHeight); // 0x004026F0 void __cdecl phd_PopMatrix(); // ---------- void __cdecl phd_PushMatrix(); // 0x00457510 void __cdecl phd_PushUnitMatrix(); // 0x0045752E #endif // _3DGEN_H_INCLUDED ================================================ FILE: 3dsystem/3d_out.cpp ================================================ /* * Copyright (c) 2017-2020 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #include "global/precompiled.h" #include "3dsystem/3d_out.h" #include "global/vars.h" #pragma pack(push, 1) typedef struct { UINT16 x; UINT16 y; } XGEN_X; typedef struct { UINT16 x; UINT16 y; UINT16 g; } XGEN_XG; typedef struct { UINT16 x; UINT16 y; UINT16 g; UINT16 u; UINT16 v; } XGEN_XGUV; typedef struct { UINT16 x; UINT16 y; UINT16 g; float rhw; float u; float v; } XGEN_XGUVP; typedef struct { int x0; int x1; } XBUF_X; typedef struct { int x0; int g0; int x1; int g1; } XBUF_XG; typedef struct { int x0; int g0; int u0; int v0; int x1; int g1; int u1; int v1; } XBUF_XGUV; typedef struct { int x0; int g0; float u0; float v0; float rhw0; int x1; int g1; float u1; float v1; float rhw1; } XBUF_XGUVP; #pragma pack(pop) #ifdef FEATURE_NOLEGACY_OPTIONS static int SwrPitch = 0; static int SwrHeight = 0; static void *XBuffer = NULL; int GetPitchSWR() { return SwrPitch; } void PrepareSWR(int pitch, int height) { if( pitch != 0 ) { SwrPitch = pitch; } if( height != 0 && (XBuffer == NULL || SwrHeight != height) ) { SwrHeight = height; if( XBuffer != NULL ) free(XBuffer); XBuffer = malloc(sizeof(XBUF_XGUVP) * height); } } #else // FEATURE_NOLEGACY_OPTIONS #define SwrPitch PhdScreenWidth // NOTE: this is the original game bug! static int XBuffer[1200 * sizeof(XBUF_XGUVP) / sizeof(int)]; // maximum safe resolution is 1200 pixels #endif // FEATURE_NOLEGACY_OPTIONS void __cdecl draw_poly_line(__int16 *bufPtr) { int i, j; int x0, y0, x1, y1; int xSize, ySize, xAdd, yAdd, colAdd, rowAdd; int swapBuf, part, partTotal; BYTE colorIdx; BYTE *drawPtr; x0 = *(bufPtr++); y0 = *(bufPtr++); x1 = *(bufPtr++); y1 = *(bufPtr++); colorIdx = (BYTE)*bufPtr; if( x1 < x0 ) { SWAP(x0, x1, swapBuf); SWAP(y0, y1, swapBuf); } if( x1 < 0 || x0 > PhdWinMaxX ) return; if( x0 < 0 ) { y0 -= x0 * (y1 - y0) / (x1 - x0); x0 = 0; } if( x1 > PhdWinMaxX ) { y1 = y0 + (y1 - y0) * (PhdWinMaxX - x0) / (x1 - x0); x1 = PhdWinMaxX; } if( y1 < y0 ) { SWAP(x0, x1, swapBuf); SWAP(y0, y1, swapBuf); } if( y1 < 0 || y0 > PhdWinMaxY ) return; if( y0 < 0 ) { x0 -= y0 * (x1 - x0) / (y1 - y0); y0 = 0; } if( y1 > PhdWinMaxY ) { x1 = x0 + (x1 - x0) * (PhdWinMaxY - y0) / (y1 - y0); y1 = PhdWinMaxY; } drawPtr = PrintSurfacePtr + (SwrPitch * y0 + x0); xSize = x1 - x0; ySize = y1 - y0; if( (xSize|ySize) == 0 ) { *drawPtr = colorIdx; return; } if( xSize < 0 ) { xSize = -xSize; xAdd = -1; } else { xAdd = 1; } if( ySize < 0 ) { ySize = -ySize; yAdd = -SwrPitch; } else { yAdd = SwrPitch; } if( xSize >= ySize ) { i = xSize + 1; j = ySize + 1; colAdd = xAdd; rowAdd = yAdd; } else { i = ySize + 1; j = xSize + 1; colAdd = yAdd; rowAdd = xAdd; } partTotal = 0; part = PHD_ONE * j / i; while( i-- ) { partTotal += part; *drawPtr = colorIdx; drawPtr += colAdd; if( partTotal >= PHD_ONE ) { drawPtr += rowAdd; partTotal -= PHD_ONE; } } } void __cdecl draw_poly_flat(__int16 *bufPtr) { if( xgen_x(bufPtr + 1) ) flatA(XGen_y0, XGen_y1, *bufPtr); } void __cdecl draw_poly_trans(__int16 *bufPtr) { if( xgen_x(bufPtr + 1) ) transA(XGen_y0, XGen_y1, *bufPtr); } void __cdecl draw_poly_gouraud(__int16 *bufPtr) { if( xgen_xg(bufPtr + 1) ) gourA(XGen_y0, XGen_y1, *bufPtr); } void __cdecl draw_poly_gtmap(__int16 *bufPtr) { if( xgen_xguv(bufPtr + 1) ) gtmapA(XGen_y0, XGen_y1, TexturePageBuffer8[*bufPtr]); } void __cdecl draw_poly_wgtmap(__int16 *bufPtr) { if( xgen_xguv(bufPtr + 1) ) wgtmapA(XGen_y0, XGen_y1, TexturePageBuffer8[*bufPtr]); } BOOL __cdecl xgen_x(__int16 *bufPtr) { int ptCount; XGEN_X *pt1, *pt2; int yMin, yMax; int x1, y1, x2, y2; int xSize, ySize; int x, xAdd; XBUF_X *xPtr; ptCount = *bufPtr++; pt2 = (XGEN_X *)bufPtr; pt1 = pt2 + (ptCount - 1); yMin = yMax = pt1->y; while( ptCount-- ) { x1 = pt1->x; y1 = pt1->y; x2 = pt2->x; y2 = pt2->y; pt1 = pt2++; if( y1 < y2 ) { CLAMPG(yMin, y1); xSize = x2 - x1; ySize = y2 - y1; xPtr = (XBUF_X *)XBuffer + y1; xAdd = PHD_ONE * xSize / ySize; x = x1 * PHD_ONE + (PHD_ONE - 1); do { (xPtr++)->x1 = (x += xAdd); } while( --ySize ); } else if( y2 < y1 ) { CLAMPL(yMax, y1); xSize = x1 - x2; ySize = y1 - y2; xPtr = (XBUF_X *)XBuffer + y2; xAdd = PHD_ONE * xSize / ySize; x = x2 * PHD_ONE + 1; do { (xPtr++)->x0 = (x += xAdd); } while( --ySize ); } } if( yMin == yMax ) return FALSE; XGen_y0 = yMin; XGen_y1 = yMax; return TRUE; } BOOL __cdecl xgen_xg(__int16 *bufPtr) { int ptCount; XGEN_XG *pt1, *pt2; int yMin, yMax; int x1, y1, g1, x2, y2, g2; int xSize, ySize, gSize; int x, g, xAdd, gAdd; XBUF_XG *xgPtr; ptCount = *bufPtr++; pt2 = (XGEN_XG *)bufPtr; pt1 = pt2 + (ptCount - 1); yMin = yMax = pt1->y; while( ptCount-- ) { x1 = pt1->x; y1 = pt1->y; g1 = pt1->g; x2 = pt2->x; y2 = pt2->y; g2 = pt2->g; pt1 = pt2++; if( y1 < y2 ) { CLAMPG(yMin, y1); xSize = x2 - x1; ySize = y2 - y1; gSize = g2 - g1; xgPtr = (XBUF_XG *)XBuffer + y1; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; x = x1 * PHD_ONE + (PHD_ONE - 1); g = g1 * PHD_HALF; do { xgPtr->x1 = (x += xAdd); xgPtr->g1 = (g += gAdd); xgPtr++; } while( --ySize ); } else if( y2 < y1 ) { CLAMPL(yMax, y1); xSize = x1 - x2; ySize = y1 - y2; gSize = g1 - g2; xgPtr = (XBUF_XG *)XBuffer + y2; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; x = x2 * PHD_ONE + 1; g = g2 * PHD_HALF; do { xgPtr->x0 = (x += xAdd); xgPtr->g0 = (g += gAdd); xgPtr++; } while( --ySize ); } } if( yMin == yMax ) return FALSE; XGen_y0 = yMin; XGen_y1 = yMax; return TRUE; } BOOL __cdecl xgen_xguv(__int16 *bufPtr) { int ptCount; XGEN_XGUV *pt1, *pt2; int yMin, yMax; int x1, y1, g1, u1, v1, x2, y2, g2, u2, v2; int xSize, ySize, gSize, uSize, vSize; int x, g, u, v, xAdd, gAdd, uAdd, vAdd; XBUF_XGUV *xguvPtr; ptCount = *bufPtr++; pt2 = (XGEN_XGUV *)bufPtr; pt1 = pt2 + (ptCount - 1); yMin = yMax = pt1->y; while( ptCount-- ) { x1 = pt1->x; y1 = pt1->y; g1 = pt1->g; u1 = pt1->u; v1 = pt1->v; x2 = pt2->x; y2 = pt2->y; g2 = pt2->g; u2 = pt2->u; v2 = pt2->v; pt1 = pt2++; if( y1 < y2 ) { CLAMPG(yMin, y1); xSize = x2 - x1; ySize = y2 - y1; gSize = g2 - g1; uSize = u2 - u1; vSize = v2 - v1; xguvPtr = (XBUF_XGUV *)XBuffer + y1; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; uAdd = PHD_HALF * uSize / ySize; vAdd = PHD_HALF * vSize / ySize; x = x1 * PHD_ONE + (PHD_ONE - 1); g = g1 * PHD_HALF; u = u1 * PHD_HALF; v = v1 * PHD_HALF; do { xguvPtr->x1 = (x += xAdd); xguvPtr->g1 = (g += gAdd); xguvPtr->u1 = (u += uAdd); xguvPtr->v1 = (v += vAdd); xguvPtr++; } while( --ySize ); } else if( y2 < y1 ) { CLAMPL(yMax, y1); xSize = x1 - x2; ySize = y1 - y2; gSize = g1 - g2; uSize = u1 - u2; vSize = v1 - v2; xguvPtr = (XBUF_XGUV *)XBuffer + y2; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; uAdd = PHD_HALF * uSize / ySize; vAdd = PHD_HALF * vSize / ySize; x = x2 * PHD_ONE + 1; g = g2 * PHD_HALF; u = u2 * PHD_HALF; v = v2 * PHD_HALF; do { xguvPtr->x0 = (x += xAdd); xguvPtr->g0 = (g += gAdd); xguvPtr->u0 = (u += uAdd); xguvPtr->v0 = (v += vAdd); xguvPtr++; } while( --ySize ); } } if( yMin == yMax ) return FALSE; XGen_y0 = yMin; XGen_y1 = yMax; return TRUE; } BOOL __cdecl xgen_xguvpersp_fp(__int16 *bufPtr) { int ptCount; XGEN_XGUVP *pt1, *pt2; int yMin, yMax; int x1, y1, g1, x2, y2, g2; float u1, v1, rhw1, u2, v2, rhw2; int xSize, ySize, gSize; float uSize, vSize, rhwSize; int x, g, xAdd, gAdd; float u, v, rhw, uAdd, vAdd, rhwAdd; XBUF_XGUVP *xguvPtr; ptCount = *bufPtr++; pt2 = (XGEN_XGUVP *)bufPtr; pt1 = pt2 + (ptCount - 1); yMin = yMax = pt1->y; while( ptCount-- ) { x1 = pt1->x; y1 = pt1->y; g1 = pt1->g; u1 = pt1->u; v1 = pt1->v; rhw1 = pt1->rhw; x2 = pt2->x; y2 = pt2->y; g2 = pt2->g; u2 = pt2->u; v2 = pt2->v; rhw2 = pt2->rhw; pt1 = pt2++; if( y1 < y2 ) { CLAMPG(yMin, y1); xSize = x2 - x1; ySize = y2 - y1; gSize = g2 - g1; uSize = u2 - u1; vSize = v2 - v1; rhwSize = rhw2 - rhw1; xguvPtr = (XBUF_XGUVP *)XBuffer + y1; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; uAdd = uSize / (float)ySize; vAdd = vSize / (float)ySize; rhwAdd = rhwSize / (float)ySize; x = x1 * PHD_ONE + (PHD_ONE - 1); g = g1 * PHD_HALF; u = u1; v = v1; rhw = rhw1; do { xguvPtr->x1 = (x += xAdd); xguvPtr->g1 = (g += gAdd); xguvPtr->u1 = (u += uAdd); xguvPtr->v1 = (v += vAdd); xguvPtr->rhw1 = (rhw += rhwAdd); xguvPtr++; } while( --ySize ); } else if( y2 < y1 ) { CLAMPL(yMax, y1); xSize = x1 - x2; ySize = y1 - y2; gSize = g1 - g2; uSize = u1 - u2; vSize = v1 - v2; rhwSize = rhw1 - rhw2; xguvPtr = (XBUF_XGUVP *)XBuffer + y2; xAdd = PHD_ONE * xSize / ySize; gAdd = PHD_HALF * gSize / ySize; uAdd = (float)uSize / (float)ySize; vAdd = (float)vSize / (float)ySize; rhwAdd = (float)rhwSize / (float)ySize; x = x2 * PHD_ONE + 1; g = g2 * PHD_HALF; u = (float)u2; v = (float)v2; rhw = (float)rhw2; do { xguvPtr->x0 = (x += xAdd); xguvPtr->g0 = (g += gAdd); xguvPtr->u0 = (u += uAdd); xguvPtr->v0 = (v += vAdd); xguvPtr->rhw0 = (rhw += rhwAdd); xguvPtr++; } while( --ySize ); } } if( yMin == yMax ) return FALSE; XGen_y0 = yMin; XGen_y1 = yMax; return TRUE; } void __cdecl gtmap_persp32_fp(int y0, int y1, BYTE *texPage) { int batchSize, batchCounter; int x, xSize, ySize; int g, u0, u1, v0, v1, gAdd, u0Add, v0Add; double u, v, rhw, uAdd, vAdd, rhwAdd; BYTE *drawPtr, *linePtr; XBUF_XGUVP *xbuf; BYTE colorIdx; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_XGUVP *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; g = xbuf->g0; u = xbuf->u0; v = xbuf->v0; rhw = xbuf->rhw0; gAdd = (xbuf->g1 - g) / xSize; u0 = (int)(PHD_HALF * u / rhw); v0 = (int)(PHD_HALF * v / rhw); linePtr = drawPtr + x; batchSize = 32; if( xSize >= batchSize ) { uAdd = (xbuf->u1 - u) / (double)xSize * double(batchSize); vAdd = (xbuf->v1 - v) / (double)xSize * double(batchSize); rhwAdd = (xbuf->rhw1 - rhw) / (double)xSize * double(batchSize); do { u += uAdd; v += vAdd; rhw += rhwAdd; u1 = (int)(PHD_HALF * u / rhw); v1 = (int)(PHD_HALF * v / rhw); u0Add = (u1 - u0) / batchSize; v0Add = (v1 - v0) / batchSize; if( (ABS(u0Add) + ABS(v0Add)) < (PHD_ONE / 2) ) { batchCounter = batchSize / 2; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; colorIdx = DepthQTable[BYTE2(g)].index[colorIdx]; *(linePtr++) = colorIdx; *(linePtr++) = colorIdx; g += gAdd * 2; u0 += u0Add * 2; v0 += v0Add * 2; } while( --batchCounter ); } else { batchCounter = batchSize; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; *(linePtr++) = DepthQTable[BYTE2(g)].index[colorIdx]; g += gAdd; u0 += u0Add; v0 += v0Add; } while( --batchCounter ); } u0 = u1; v0 = v1; xSize -= batchSize; } while( xSize >= batchSize ); } if( xSize > 1 ) { u1 = (int)(PHD_HALF * xbuf->u1 / xbuf->rhw1); v1 = (int)(PHD_HALF * xbuf->v1 / xbuf->rhw1); u0Add = (u1 - u0) / xSize; v0Add = (v1 - v0) / xSize; batchSize = xSize & ~1; xSize -= batchSize; if( (ABS(u0Add) + ABS(v0Add)) < (PHD_ONE / 2) ) { batchCounter = batchSize / 2; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; colorIdx = DepthQTable[BYTE2(g)].index[colorIdx]; *(linePtr++) = colorIdx; *(linePtr++) = colorIdx; g += gAdd * 2; u0 += u0Add * 2; v0 += v0Add * 2; } while( --batchCounter ); } else { batchCounter = batchSize; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; *(linePtr++) = DepthQTable[BYTE2(g)].index[colorIdx]; g += gAdd; u0 += u0Add; v0 += v0Add; } while( --batchCounter ); } } if( xSize != 0 ) { // xSize == 1 colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; *linePtr = DepthQTable[BYTE2(g)].index[colorIdx]; } } } void __cdecl wgtmap_persp32_fp(int y0, int y1, BYTE *texPage) { int batchSize, batchCounter; int x, xSize, ySize; int g, u0, u1, v0, v1, gAdd, u0Add, v0Add; double u, v, rhw, uAdd, vAdd, rhwAdd; BYTE *drawPtr, *linePtr; XBUF_XGUVP *xbuf; BYTE colorIdx; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_XGUVP *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; g = xbuf->g0; u = xbuf->u0; v = xbuf->v0; rhw = xbuf->rhw0; gAdd = (xbuf->g1 - g) / xSize; u0 = (int)(PHD_HALF * u / rhw); v0 = (int)(PHD_HALF * v / rhw); linePtr = drawPtr + x; batchSize = 32; if( xSize >= batchSize ) { uAdd = (xbuf->u1 - u) / (double)xSize * double(batchSize); vAdd = (xbuf->v1 - v) / (double)xSize * double(batchSize); rhwAdd = (xbuf->rhw1 - rhw) / (double)xSize * double(batchSize); do { u += uAdd; v += vAdd; rhw += rhwAdd; u1 = (int)(PHD_HALF * u / rhw); v1 = (int)(PHD_HALF * v / rhw); u0Add = (u1 - u0) / batchSize; v0Add = (v1 - v0) / batchSize; if( (ABS(u0Add) + ABS(v0Add)) < (PHD_ONE / 2) ) { batchCounter = batchSize / 2; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; if( colorIdx != 0 ) { colorIdx = DepthQTable[BYTE2(g)].index[colorIdx]; linePtr[0] = colorIdx; linePtr[1] = colorIdx; } linePtr += 2; g += gAdd * 2; u0 += u0Add * 2; v0 += v0Add * 2; } while( --batchCounter ); } else { batchCounter = batchSize; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; if( colorIdx != 0 ) { *linePtr = DepthQTable[BYTE2(g)].index[colorIdx]; } linePtr++; g += gAdd; u0 += u0Add; v0 += v0Add; } while( --batchCounter ); } u0 = u1; v0 = v1; xSize -= batchSize; } while( xSize >= batchSize ); } if( xSize > 1 ) { u1 = (int)(PHD_HALF * xbuf->u1 / xbuf->rhw1); v1 = (int)(PHD_HALF * xbuf->v1 / xbuf->rhw1); u0Add = (u1 - u0) / xSize; v0Add = (v1 - v0) / xSize; batchSize = xSize & ~1; xSize -= batchSize; if( (ABS(u0Add) + ABS(v0Add)) < (PHD_ONE / 2) ) { batchCounter = batchSize / 2; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; if( colorIdx != 0 ) { colorIdx = DepthQTable[BYTE2(g)].index[colorIdx]; linePtr[0] = colorIdx; linePtr[1] = colorIdx; } linePtr += 2; g += gAdd * 2; u0 += u0Add * 2; v0 += v0Add * 2; } while( --batchCounter ); } else { batchCounter = batchSize; do { colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; if( colorIdx != 0 ) { *linePtr = DepthQTable[BYTE2(g)].index[colorIdx]; } linePtr++; g += gAdd; u0 += u0Add; v0 += v0Add; } while( --batchCounter ); } } if( xSize != 0 ) { // xSize == 1 colorIdx = texPage[BYTE2(v0)*256 + BYTE2(u0)]; if( colorIdx != 0 ) { *linePtr = DepthQTable[BYTE2(g)].index[colorIdx]; } } } } void __cdecl draw_poly_gtmap_persp(__int16 *bufPtr) { if( xgen_xguvpersp_fp(bufPtr + 1) ) gtmap_persp32_fp(XGen_y0, XGen_y1, TexturePageBuffer8[*bufPtr]); } void __cdecl draw_poly_wgtmap_persp(__int16 *bufPtr) { if( xgen_xguvpersp_fp(bufPtr + 1) ) wgtmap_persp32_fp(XGen_y0, XGen_y1, TexturePageBuffer8[*bufPtr]); } void __fastcall flatA(int y0, int y1, BYTE colorIdx) { int x, xSize, ySize; BYTE *drawPtr; XBUF_X *xbuf; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_X *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize > 0 ) { memset(drawPtr + x, colorIdx, xSize); } } } void __fastcall transA(int y0, int y1, BYTE depthQ) { int x, xSize, ySize; BYTE *drawPtr, *linePtr; XBUF_X *xbuf; DEPTHQ_ENTRY *qt; ySize = y1 - y0; if( ySize <= 0 || depthQ >= 32 ) // NOTE: depthQ check was ( > 32) in the original code return; xbuf = (XBUF_X *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; qt = DepthQTable + depthQ; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; linePtr = drawPtr + x; do { *linePtr = qt->index[*linePtr]; ++linePtr; } while( --xSize ); } } void __fastcall gourA(int y0, int y1, BYTE colorIdx) { int x, xSize, ySize; int g, gAdd; BYTE *drawPtr, *linePtr; XBUF_XG *xbuf; GOURAUD_ENTRY *gt; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_XG *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; gt = GouraudTable + colorIdx; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; g = xbuf->g0; gAdd = (xbuf->g1 - g) / xSize; linePtr = drawPtr + x; do { *(linePtr++) = gt->index[BYTE2(g)]; g += gAdd; } while( --xSize ); } } void __fastcall gtmapA(int y0, int y1, BYTE *texPage) { int x, xSize, ySize; int g, u, v, gAdd, uAdd, vAdd; BYTE *drawPtr, *linePtr; XBUF_XGUV *xbuf; BYTE colorIdx; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_XGUV *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; g = xbuf->g0; u = xbuf->u0; v = xbuf->v0; gAdd = (xbuf->g1 - g) / xSize; uAdd = (xbuf->u1 - u) / xSize; vAdd = (xbuf->v1 - v) / xSize; linePtr = drawPtr + x; do { colorIdx = texPage[BYTE2(v)*256 + BYTE2(u)]; *(linePtr++) = DepthQTable[BYTE2(g)].index[colorIdx]; g += gAdd; u += uAdd; v += vAdd; } while( --xSize ); } } void __fastcall wgtmapA(int y0, int y1, BYTE *texPage) { int x, xSize, ySize; int g, u, v, gAdd, uAdd, vAdd; BYTE *drawPtr, *linePtr; XBUF_XGUV *xbuf; BYTE colorIdx; ySize = y1 - y0; if( ySize <= 0 ) return; xbuf = (XBUF_XGUV *)XBuffer + y0; drawPtr = PrintSurfacePtr + y0 * SwrPitch; for( ; ySize > 0; --ySize, ++xbuf, drawPtr += SwrPitch ) { x = xbuf->x0 / PHD_ONE; xSize = (xbuf->x1 / PHD_ONE) - x; if( xSize <= 0 ) continue; g = xbuf->g0; u = xbuf->u0; v = xbuf->v0; gAdd = (xbuf->g1 - g) / xSize; uAdd = (xbuf->u1 - u) / xSize; vAdd = (xbuf->v1 - v) / xSize; linePtr = drawPtr + x; do { colorIdx = texPage[BYTE2(v)*256 + BYTE2(u)]; if( colorIdx != 0 ) { *linePtr = DepthQTable[BYTE2(g)].index[colorIdx]; } ++linePtr; g += gAdd; u += uAdd; v += vAdd; } while( --xSize ); } } /* * Inject function */ void Inject_3Dout() { INJECT(0x00402960, draw_poly_line); INJECT(0x00402B00, draw_poly_flat); INJECT(0x00402B40, draw_poly_trans); INJECT(0x00402B80, draw_poly_gouraud); INJECT(0x00402BC0, draw_poly_gtmap); INJECT(0x00402C00, draw_poly_wgtmap); INJECT(0x00402C40, xgen_x); INJECT(0x00402D20, xgen_xg); INJECT(0x00402E70, xgen_xguv); INJECT(0x00403090, xgen_xguvpersp_fp); INJECT(0x00403320, gtmap_persp32_fp); INJECT(0x004042F0, wgtmap_persp32_fp); INJECT(0x004057C0, draw_poly_gtmap_persp); INJECT(0x00405800, draw_poly_wgtmap_persp); // NOTE: asm functions below use Watcom register calling convention so they incompatible // INJECT(0x00457564, flatA); // INJECT(0x004575C5, transA); // INJECT(0x004576FF, gourA); // INJECT(0x0045785F, gtmapA); // INJECT(0x00457B5C, wgtmapA); } ================================================ FILE: 3dsystem/3d_out.h ================================================ /* * Copyright (c) 2017-2018 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #ifndef _3DOUT_H_INCLUDED #define _3DOUT_H_INCLUDED #include "global/types.h" /* * Function list */ void __cdecl draw_poly_line(__int16 *bufPtr); // 0x00402960 void __cdecl draw_poly_flat(__int16 *bufPtr); // 0x00402B00 void __cdecl draw_poly_trans(__int16 *bufPtr); // 0x00402B40 void __cdecl draw_poly_gouraud(__int16 *bufPtr); // 0x00402B80 void __cdecl draw_poly_gtmap(__int16 *bufPtr); // 0x00402BC0 void __cdecl draw_poly_wgtmap(__int16 *bufPtr); // 0x00402C00 BOOL __cdecl xgen_x(__int16 *bufPtr); // 0x00402C40 BOOL __cdecl xgen_xg(__int16 *bufPtr); // 0x00402D20 BOOL __cdecl xgen_xguv(__int16 *bufPtr); // 0x00402E70 BOOL __cdecl xgen_xguvpersp_fp(__int16 *bufPtr); // 0x00403090 void __cdecl gtmap_persp32_fp(int y0, int y1, BYTE *texPage); // 0x00403320 void __cdecl wgtmap_persp32_fp(int y0, int y1, BYTE *texPage); // 0x004042F0 void __cdecl draw_poly_gtmap_persp(__int16 *bufPtr); // 0x004057C0 void __cdecl draw_poly_wgtmap_persp(__int16 *bufPtr); // 0x00405800 void __fastcall flatA(int y0, int y1, BYTE colorIdx); // 0x00457564 void __fastcall transA(int y0, int y1, BYTE depthQ); // 0x004575C5 void __fastcall gourA(int y0, int y1, BYTE colorIdx); // 0x004576FF void __fastcall gtmapA(int y0, int y1, BYTE *texPage); // 0x0045785F void __fastcall wgtmapA(int y0, int y1, BYTE *texPage); // 0x00457B5C #endif // _3DOUT_H_INCLUDED ================================================ FILE: 3dsystem/3dinsert.cpp ================================================ /* * Copyright (c) 2017-2021 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #include "global/precompiled.h" #include "3dsystem/3dinsert.h" #include "specific/hwr.h" #include "global/vars.h" #if defined(FEATURE_HUD_IMPROVED) || (DIRECT3D_VERSION >= 0x900) #include "modding/texture_utils.h" #endif // defined(FEATURE_HUD_IMPROVED) || (DIRECT3D_VERSION >= 0x900) #ifdef FEATURE_VIDEOFX_IMPROVED #include "specific/texture.h" #include "modding/mod_utils.h" extern DWORD ShadowMode; extern DWORD AlphaBlendMode; bool CustomWaterColorEnabled = true; #endif // FEATURE_VIDEOFX_IMPROVED static VERTEX_INFO VBuffer[40]; // NOTE: original size was 20 static D3DTLVERTEX VBufferD3D[32]; static D3DCOLOR GlobalTint = 0; // NOTE: not presented in the original code #ifdef FEATURE_VIEW_IMPROVED bool RoomSortEnabled = false; #define MAKE_ZSORT(z) (RoomSortEnabled && (SavedAppSettings.RenderMode == RM_Software || !SavedAppSettings.ZBuffer) ? (((UINT64)MidSort)<<32)+(DWORD)(z) : (DWORD)(z)) #else // FEATURE_VIEW_IMPROVED #define MAKE_ZSORT(z) ((DWORD)(z)) #endif // FEATURE_VIEW_IMPROVED static D3DCOLOR shadeColor(DWORD red, DWORD green, DWORD blue, DWORD alpha, DWORD shade, bool isTextured) { CLAMPG(shade, 0x1FFF); if( GlobalTint ) { red = RGBA_GETRED(GlobalTint); green = RGBA_GETGREEN(GlobalTint); blue = RGBA_GETBLUE(GlobalTint); alpha = RGBA_GETALPHA(GlobalTint); } #if defined(FEATURE_VIDEOFX_IMPROVED) && (DIRECT3D_VERSION >= 0x900) if( SavedAppSettings.LightingMode == 1 ) CLAMPL(shade, 0x800); if( SavedAppSettings.LightingMode && isTextured ) shade = 0x1000 + shade/2; if( !SavedAppSettings.LightingMode && !isTextured ) CLAMPL(shade, 0x1000); #else // defined(FEATURE_VIDEOFX_IMPROVED) && (DIRECT3D_VERSION >= 0x900) // NOTE: The original game bugfix. We need to limit brightness of untextured faces for DirectX 5 // because brightness of textured faces is limited by D3DTBLEND_MODULATEALPHA or D3DTBLEND_MODULATE if( !isTextured ) CLAMPL(shade, 0x1000); #endif // defined(FEATURE_VIDEOFX_IMPROVED) && (DIRECT3D_VERSION >= 0x900) if( shade != 0x1000 ) { DWORD brightness = 0x2000 - shade; red = red * brightness >> 12; green = green * brightness >> 12; blue = blue * brightness >> 12; } CLAMPG(red, 0xFF); CLAMPG(green, 0xFF); CLAMPG(blue, 0xFF); CLAMPG(alpha, 0xFF); if( IsShadeEffect ) { #if defined(FEATURE_VIDEOFX_IMPROVED) && defined(FEATURE_MOD_CONFIG) D3DCOLOR water = GetModWaterColor(); if( CustomWaterColorEnabled && water ) { red = red * RGB_GETRED(water) / 256; green = green * RGB_GETGREEN(water) / 256; blue = blue * RGB_GETBLUE(water) / 256; } else { red = red * 128 / 256; green = green * 224 / 256; } #else // defined(FEATURE_VIDEOFX_IMPROVED) && defined(FEATURE_MOD_CONFIG) red = red * 128 / 256; green = green * 224 / 256; #endif // defined(FEATURE_VIDEOFX_IMPROVED) && defined(FEATURE_MOD_CONFIG) } return RGBA_MAKE(red, green, blue, alpha); } static double CalculatePolyZ(SORTTYPE sortType, double z0, double z1, double z2, double z3 = -1.0) { double zv = 0.0; switch( sortType ) { case ST_AvgZ : zv = ( z3 > 0.0 ) ? (z0+z1+z2+z3)/4.0 : (z0+z1+z2)/3.0; break; case ST_MaxZ : zv = z0; CLAMPL(zv, z1); CLAMPL(zv, z2); if( z3 > 0.0 ) CLAMPL(zv, z3); break; case ST_FarZ : default : zv = 4000000000.0; // the original game value was 1000000000.0 break; } return zv; } #ifdef FEATURE_VIDEOFX_IMPROVED static POLYTYPE GetPolyType(UINT16 drawtype) { switch( drawtype ) { case DRAW_Opaque: return POLY_HWR_GTmap; case DRAW_Semitrans: return AlphaBlendMode ? POLY_HWR_WGTmapHalf : POLY_HWR_WGTmap; case DRAW_ColorKey: return POLY_HWR_WGTmap; } return POLY_HWR_WGTmap; } bool InsertObjectEM(__int16 *ptrObj, int vtxCount, D3DCOLOR tint, PHD_UV *em_uv) { PHD_VBUF *vtx[4]; PHD_TEXTURE texture; PHD_UV *uv = texture.uv; if( ptrObj == NULL || em_uv == NULL || vtxCount < 3 || vtxCount > 4 ) { return false; } texture.drawtype = DRAW_ColorKey; texture.tpage = (UINT16)~0; for( int i = 0; i < vtxCount; ++ i ) { vtx[i] = &PhdVBuf[ptrObj[i]]; texture.uv[i] = em_uv[ptrObj[i]]; } GlobalTint = tint; if( vtxCount == 4 ) { InsertGT4_Sorted(vtx[0], vtx[1], vtx[2], vtx[3], &texture, ST_AvgZ); } else { InsertGT3_Sorted(vtx[0], vtx[1], vtx[2], &texture, &uv[0], &uv[1], &uv[2], ST_AvgZ); } GlobalTint = 0; return true; } #endif // FEATURE_VIDEOFX_IMPROVED // NOTE: this function is not presented in the original game void __cdecl InsertGourQuad(int x0, int y0, int x1, int y1, int z, D3DCOLOR color0, D3DCOLOR color1, D3DCOLOR color2, D3DCOLOR color3) { double rhw, sz; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_HWR_trans; *(Info3dPtr++) = 4; // vertex count *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; HWR_VertexPtr[0].sx = (float)x1; HWR_VertexPtr[0].sy = (float)y0; HWR_VertexPtr[0].color = color1; HWR_VertexPtr[1].sx = (float)x1; HWR_VertexPtr[1].sy = (float)y1; HWR_VertexPtr[1].color = color2; HWR_VertexPtr[2].sx = (float)x0; HWR_VertexPtr[2].sy = (float)y1; HWR_VertexPtr[2].color = color3; HWR_VertexPtr[3].sx = (float)x0; HWR_VertexPtr[3].sy = (float)y0; HWR_VertexPtr[3].color = color0; for( int i=0; i<4; ++i ) { HWR_VertexPtr[i].sz = sz; HWR_VertexPtr[i].rhw = rhw; } HWR_VertexPtr += 4; ++SurfaceCount; } BOOL __cdecl visible_zclip(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2) { return ( (vtx0->yv * vtx2->zv - vtx0->zv * vtx2->yv) * vtx1->xv + (vtx0->zv * vtx2->xv - vtx0->xv * vtx2->zv) * vtx1->yv + (vtx0->xv * vtx2->yv - vtx0->yv * vtx2->xv) * vtx1->zv < 0.0 ); } int __cdecl ZedClipper(int vtxCount, POINT_INFO *pts, VERTEX_INFO *vtx) { int i, j, diff0, diff1; double clip; POINT_INFO *pts0, *pts1; if( vtxCount == 0 ) return 0; j = 0; pts0 = pts; pts1 = &pts[vtxCount-1]; for( i = 0; i < vtxCount; ++i ) { diff0 = (int)(FltNearZ - pts0->zv); diff1 = (int)(FltNearZ - pts1->zv); if( (diff0|diff1) < 0 ) { if( (diff0^diff1) < 0 ) { clip = (FltNearZ - pts0->zv) / (pts1->zv - pts0->zv); vtx[j].x = ((pts1->xv - pts0->xv) * clip + pts0->xv) * FltPerspONearZ + FltWinCenterX; vtx[j].y = ((pts1->yv - pts0->yv) * clip + pts0->yv) * FltPerspONearZ + FltWinCenterY; vtx[j].rhw = FltRhwONearZ; vtx[j].u = ((pts1->u - pts0->u) * clip + pts0->u) * FltRhwONearZ; vtx[j].v = ((pts1->v - pts0->v) * clip + pts0->v) * FltRhwONearZ; vtx[j].g = ((pts1->g - pts0->g) * clip + pts0->g); ++j; } if( diff0 < 0 ) { vtx[j].x = pts0->xs; vtx[j].y = pts0->ys; vtx[j].rhw = pts0->rhw; vtx[j].u = pts0->u * pts0->rhw; vtx[j].v = pts0->v * pts0->rhw; vtx[j].g = pts0->g; ++j; } } pts1 = pts0++; } return ( j < 3 ) ? 0 : j; } static inline void clipGUV(VERTEX_INFO *buf, VERTEX_INFO *vtx1, VERTEX_INFO *vtx2, float clip) { buf->rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; buf->u = vtx2->u + (vtx1->u - vtx2->u) * clip; buf->v = vtx2->v + (vtx1->v - vtx2->v) * clip; buf->g = vtx2->g + (vtx1->g - vtx2->g) * clip; } int __cdecl XYGUVClipper(int vtxCount, VERTEX_INFO *vtx) { VERTEX_INFO vtx_buf[8]; VERTEX_INFO *vtx1, *vtx2; float clip; int i, j; if( vtxCount < 3 ) return 0; // horizontal clip vtx2 = &vtx[vtxCount - 1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx[i]; if( vtx1->x < FltWinLeft ) { if( vtx2->x < FltWinLeft ) { continue; } clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipGUV(&vtx_buf[j++], vtx1, vtx2, clip); } else if( vtx1->x > FltWinRight) { if( vtx2->x > FltWinRight ) { continue; } clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipGUV(&vtx_buf[j++], vtx1, vtx2, clip); } if( vtx2->x < FltWinLeft ) { clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipGUV(&vtx_buf[j++], vtx1, vtx2, clip); } else if( vtx2->x > FltWinRight ) { clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipGUV(&vtx_buf[j++], vtx1, vtx2, clip); } else { vtx_buf[j++] = *vtx2; } } vtxCount = j; if( vtxCount < 3 ) return 0; // vertical clip vtx2 = &vtx_buf[vtxCount-1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx_buf[i]; if( vtx1->y < FltWinTop ) { if( vtx2->y < FltWinTop ) { continue; } clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; clipGUV(&vtx[j++], vtx1, vtx2, clip); } else if( vtx1->y > FltWinBottom ) { if( vtx2->y > FltWinBottom ) { continue; } clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; clipGUV(&vtx[j++], vtx1, vtx2, clip); } if( vtx2->y < FltWinTop ) { clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; clipGUV(&vtx[j++], vtx1, vtx2, clip); } else if( vtx2->y > FltWinBottom ) { clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; clipGUV(&vtx[j++], vtx1, vtx2, clip); } else { vtx[j++] = *vtx2; } } return ( j < 3 ) ? 0 : j; } __int16 *__cdecl InsertObjectGT4(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; int i, j, nPoints; float zv; __int16 textureIdx; PHD_TEXTURE *texture; PHD_UV *uv; POINT_INFO points[4]; for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; vtx3 = &PhdVBuf[*ptrObj++]; textureIdx = *ptrObj++; texture = &PhdTextureInfo[textureIdx]; uv = texture->uv; nPoints = 4; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; if( clipOR == 0 ) { zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; if( zv >= (double)PerspectiveDistance ) { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap : POLY_WGTmap; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 4; *Info3dPtr++ = (int)vtx0->xs; *Info3dPtr++ = (int)vtx0->ys; *Info3dPtr++ = (int)vtx0->g; *Info3dPtr++ = uv[0].u; *Info3dPtr++ = uv[0].v; *Info3dPtr++ = (int)vtx1->xs; *Info3dPtr++ = (int)vtx1->ys; *Info3dPtr++ = (int)vtx1->g; *Info3dPtr++ = uv[1].u; *Info3dPtr++ = uv[1].v; *Info3dPtr++ = (int)vtx2->xs; *Info3dPtr++ = (int)vtx2->ys; *Info3dPtr++ = (int)vtx2->g; *Info3dPtr++ = uv[2].u; *Info3dPtr++ = uv[2].v; *Info3dPtr++ = (int)vtx3->xs; *Info3dPtr++ = (int)vtx3->ys; *Info3dPtr++ = (int)vtx3->g; *Info3dPtr++ = uv[3].u; *Info3dPtr++ = uv[3].v; } else { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap_persp : POLY_WGTmap_persp; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 4; *Info3dPtr++ = (int)vtx0->xs; *Info3dPtr++ = (int)vtx0->ys; *Info3dPtr++ = (int)vtx0->g; *(float *)Info3dPtr = vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[0].u * vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[0].v * vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *Info3dPtr++ = (int)vtx1->xs; *Info3dPtr++ = (int)vtx1->ys; *Info3dPtr++ = (int)vtx1->g; *(float *)Info3dPtr = vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[1].u * vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[1].v * vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *Info3dPtr++ = (int)vtx2->xs; *Info3dPtr++ = (int)vtx2->ys; *Info3dPtr++ = (int)vtx2->g; *(float *)Info3dPtr = vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[2].u * vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[2].v * vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *Info3dPtr++ = (int)vtx3->xs; *Info3dPtr++ = (int)vtx3->ys; *Info3dPtr++ = (int)vtx3->g; *(float *)Info3dPtr = vtx3->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[3].u * vtx3->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[3].v * vtx3->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); } ++SurfaceCount; continue; } VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[0].u = (double)uv[0].u * vtx0->rhw; VBuffer[0].v = (double)uv[0].v * vtx0->rhw; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[1].u = (double)uv[1].u * vtx1->rhw; VBuffer[1].v = (double)uv[1].v * vtx1->rhw; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; VBuffer[2].u = (double)uv[2].u * vtx2->rhw; VBuffer[2].v = (double)uv[2].v * vtx2->rhw; VBuffer[3].x = vtx3->xs; VBuffer[3].y = vtx3->ys; VBuffer[3].rhw = vtx3->rhw; VBuffer[3].g = (float)vtx3->g; VBuffer[3].u = (double)uv[3].u * vtx3->rhw; VBuffer[3].v = (double)uv[3].v * vtx3->rhw; } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; points[0].xv = vtx0->xv; points[0].yv = vtx0->yv; points[0].zv = vtx0->zv; points[0].rhw = vtx0->rhw; points[0].xs = vtx0->xs; points[0].ys = vtx0->ys; points[0].u = (float)uv[0].u; points[0].v = (float)uv[0].v; points[0].g = (float)vtx0->g; points[1].yv = vtx1->yv; points[1].xv = vtx1->xv; points[1].zv = vtx1->zv; points[1].rhw = vtx1->rhw; points[1].xs = vtx1->xs; points[1].ys = vtx1->ys; points[1].u = (float)uv[1].u; points[1].v = (float)uv[1].v; points[1].g = (float)vtx1->g; points[2].xv = vtx2->xv; points[2].yv = vtx2->yv; points[2].zv = vtx2->zv; points[2].rhw = vtx2->rhw; points[2].xs = vtx2->xs; points[2].ys = vtx2->ys; points[2].u = (float)uv[2].u; points[2].v = (float)uv[2].v; points[2].g = (float)vtx2->g; points[3].xv = vtx3->xv; points[3].yv = vtx3->yv; points[3].zv = vtx3->zv; points[3].rhw = vtx3->rhw; points[3].xs = vtx3->xs; points[3].ys = vtx3->ys; points[3].u = (float)uv[3].u; points[3].v = (float)uv[3].v; points[3].g = (float)vtx3->g; nPoints = ZedClipper(nPoints, points, VBuffer); if( nPoints == 0 ) continue; } nPoints = XYGUVClipper(nPoints, VBuffer); if( nPoints == 0 ) continue; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; if( zv >= (double)PerspectiveDistance ) { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap : POLY_WGTmap; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = (int)VBuffer[j].x; *Info3dPtr++ = (int)VBuffer[j].y; *Info3dPtr++ = (int)VBuffer[j].g; *Info3dPtr++ = (int)(VBuffer[j].u / VBuffer[j].rhw); *Info3dPtr++ = (int)(VBuffer[j].v / VBuffer[j].rhw); } } else { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap_persp : POLY_WGTmap_persp; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = (int)VBuffer[j].x; *Info3dPtr++ = (int)VBuffer[j].y; *Info3dPtr++ = (int)VBuffer[j].g; *(float *)Info3dPtr = VBuffer[j].rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = VBuffer[j].u; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = VBuffer[j].v; Info3dPtr += sizeof(float)/sizeof(__int16); } } ++SurfaceCount; } return ptrObj; } __int16 *__cdecl InsertObjectGT3(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2; int i, j, nPoints; float zv; __int16 textureIdx; PHD_TEXTURE *texture; PHD_UV *uv; POINT_INFO points[3]; for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; textureIdx = *ptrObj++; texture = &PhdTextureInfo[textureIdx]; uv = texture->uv; nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; if( clipOR == 0 ) { zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; if( zv >= (double)PerspectiveDistance ) { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap : POLY_WGTmap; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 3; *Info3dPtr++ = (int)vtx0->xs; *Info3dPtr++ = (int)vtx0->ys; *Info3dPtr++ = (int)vtx0->g; *Info3dPtr++ = uv[0].u; *Info3dPtr++ = uv[0].v; *Info3dPtr++ = (int)vtx1->xs; *Info3dPtr++ = (int)vtx1->ys; *Info3dPtr++ = (int)vtx1->g; *Info3dPtr++ = uv[1].u; *Info3dPtr++ = uv[1].v; *Info3dPtr++ = (int)vtx2->xs; *Info3dPtr++ = (int)vtx2->ys; *Info3dPtr++ = (int)vtx2->g; *Info3dPtr++ = uv[2].u; *Info3dPtr++ = uv[2].v; } else { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap_persp : POLY_WGTmap_persp; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 3; *Info3dPtr++ = (int)vtx0->xs; *Info3dPtr++ = (int)vtx0->ys; *Info3dPtr++ = (int)vtx0->g; *(float *)Info3dPtr = vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[0].u * vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[0].v * vtx0->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *Info3dPtr++ = (int)vtx1->xs; *Info3dPtr++ = (int)vtx1->ys; *Info3dPtr++ = (int)vtx1->g; *(float *)Info3dPtr = vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[1].u * vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[1].v * vtx1->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *Info3dPtr++ = (int)vtx2->xs; *Info3dPtr++ = (int)vtx2->ys; *Info3dPtr++ = (int)vtx2->g; *(float *)Info3dPtr = vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[2].u * vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = (double)uv[2].v * vtx2->rhw; Info3dPtr += sizeof(float)/sizeof(__int16); } ++SurfaceCount; continue; } VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[0].u = (double)uv[0].u * vtx0->rhw; VBuffer[0].v = (double)uv[0].v * vtx0->rhw; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[1].u = (double)uv[1].u * vtx1->rhw; VBuffer[1].v = (double)uv[1].v * vtx1->rhw; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; VBuffer[2].u = (double)uv[2].u * vtx2->rhw; VBuffer[2].v = (double)uv[2].v * vtx2->rhw; } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; points[0].xv = vtx0->xv; points[0].yv = vtx0->yv; points[0].zv = vtx0->zv; points[0].rhw = vtx0->rhw; points[0].xs = vtx0->xs; points[0].ys = vtx0->ys; points[0].u = (float)uv[0].u; points[0].v = (float)uv[0].v; points[0].g = (float)vtx0->g; points[1].yv = vtx1->yv; points[1].xv = vtx1->xv; points[1].zv = vtx1->zv; points[1].rhw = vtx1->rhw; points[1].xs = vtx1->xs; points[1].ys = vtx1->ys; points[1].u = (float)uv[1].u; points[1].v = (float)uv[1].v; points[1].g = (float)vtx1->g; points[2].xv = vtx2->xv; points[2].yv = vtx2->yv; points[2].zv = vtx2->zv; points[2].rhw = vtx2->rhw; points[2].xs = vtx2->xs; points[2].ys = vtx2->ys; points[2].u = (float)uv[2].u; points[2].v = (float)uv[2].v; points[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, points, VBuffer); if( nPoints == 0 ) continue; } nPoints = XYGUVClipper(nPoints, VBuffer); if( nPoints == 0 ) continue; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; if( zv >= (double)PerspectiveDistance ) { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap : POLY_WGTmap; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = (int)VBuffer[j].x; *Info3dPtr++ = (int)VBuffer[j].y; *Info3dPtr++ = (int)VBuffer[j].g; *Info3dPtr++ = (int)(VBuffer[j].u / VBuffer[j].rhw); *Info3dPtr++ = (int)(VBuffer[j].v / VBuffer[j].rhw); } } else { *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_GTmap_persp : POLY_WGTmap_persp; *Info3dPtr++ = texture->tpage; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = (int)VBuffer[j].x; *Info3dPtr++ = (int)VBuffer[j].y; *Info3dPtr++ = (int)VBuffer[j].g; *(float *)Info3dPtr = VBuffer[j].rhw; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = VBuffer[j].u; Info3dPtr += sizeof(float)/sizeof(__int16); *(float *)Info3dPtr = VBuffer[j].v; Info3dPtr += sizeof(float)/sizeof(__int16); } } ++SurfaceCount; } return ptrObj; } static inline void clipG(VERTEX_INFO *buf, VERTEX_INFO *vtx1, VERTEX_INFO *vtx2, float clip) { buf->rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; buf->g = vtx2->g + (vtx1->g - vtx2->g) * clip; } int __cdecl XYGClipper(int vtxCount, VERTEX_INFO *vtx) { VERTEX_INFO vtx_buf[8]; VERTEX_INFO *vtx1, *vtx2; float clip; int i, j; if( vtxCount < 3 ) return 0; // horizontal clip vtx2 = &vtx[vtxCount - 1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx[i]; if( vtx1->x < FltWinLeft ) { if( vtx2->x < FltWinLeft ) { continue; } clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipG(&vtx_buf[j++], vtx1, vtx2, clip); } else if( vtx1->x > FltWinRight) { if( vtx2->x > FltWinRight ) { continue; } clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipG(&vtx_buf[j++], vtx1, vtx2, clip); } if( vtx2->x < FltWinLeft ) { clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipG(&vtx_buf[j++], vtx1, vtx2, clip); } else if( vtx2->x > FltWinRight ) { clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; clipG(&vtx_buf[j++], vtx1, vtx2, clip); } else { vtx_buf[j++] = *vtx2; } } vtxCount = j; if( vtxCount < 3 ) return 0; // vertical clip vtx2 = &vtx_buf[vtxCount-1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx_buf[i]; if( vtx1->y < FltWinTop ) { if( vtx2->y < FltWinTop ) { continue; } clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; clipG(&vtx[j++], vtx1, vtx2, clip); } else if( vtx1->y > FltWinBottom ) { if( vtx2->y > FltWinBottom ) { continue; } clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; clipG(&vtx[j++], vtx1, vtx2, clip); } if( vtx2->y < FltWinTop ) { clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; clipG(&vtx[j++], vtx1, vtx2, clip); } else if( vtx2->y > FltWinBottom ) { clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; clipG(&vtx[j++], vtx1, vtx2, clip); } else { vtx[j++] = *vtx2; } } return ( j < 3 ) ? 0 : j; } __int16 *__cdecl InsertObjectG4(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; int i, j, nPoints; float zv; BYTE colorIdx; POINT_INFO pts[4]; for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; vtx3 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 4; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; VBuffer[3].x = vtx3->xs; VBuffer[3].y = vtx3->ys; VBuffer[3].rhw = vtx3->rhw; VBuffer[3].g = (float)vtx3->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; pts[3].xv = vtx3->xv; pts[3].yv = vtx3->yv; pts[3].zv = vtx3->zv; pts[3].rhw = vtx3->rhw; pts[3].xs = vtx3->xs; pts[3].ys = vtx3->ys; pts[3].g = (float)vtx3->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints == 0 ) continue; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; *Info3dPtr++ = POLY_gouraud; *Info3dPtr++ = colorIdx; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = VBuffer[j].x; *Info3dPtr++ = VBuffer[j].y; *Info3dPtr++ = VBuffer[j].g; } ++SurfaceCount; } return ptrObj; } __int16 *__cdecl InsertObjectG3(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2; int i, j, nPoints; float zv; BYTE colorIdx; POINT_INFO pts[3]; for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints == 0 ) continue; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; *Info3dPtr++ = POLY_gouraud; *Info3dPtr++ = colorIdx; *Info3dPtr++ = nPoints; for( j = 0; j < nPoints; ++j ) { *Info3dPtr++ = (int)VBuffer[j].x; *Info3dPtr++ = (int)VBuffer[j].y; *Info3dPtr++ = (int)VBuffer[j].g; } ++SurfaceCount; } return ptrObj; } int __cdecl XYClipper(int vtxCount, VERTEX_INFO *vtx) { // NOTE: the original function ignores rhw clipping that produces bugs for Z Buffer static VERTEX_INFO vtx_buf[40]; // NOTE: original size was 20 VERTEX_INFO *vtx1, *vtx2; float clip; int i, j; if( vtxCount < 3 ) return 0; // horizontal clip vtx2 = &vtx[vtxCount - 1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx[i]; if( vtx1->x < FltWinLeft ) { if( vtx2->x < FltWinLeft ) { continue; } clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; vtx_buf[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else if( vtx1->x > FltWinRight) { if( vtx2->x > FltWinRight ) { continue; } clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; vtx_buf[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } if( vtx2->x < FltWinLeft ) { clip = (FltWinLeft - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinLeft; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; vtx_buf[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else if( vtx2->x > FltWinRight ) { clip = (FltWinRight - vtx2->x) / (vtx1->x - vtx2->x); vtx_buf[j].x = FltWinRight; vtx_buf[j].y = vtx2->y + (vtx1->y - vtx2->y) * clip; vtx_buf[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else { vtx_buf[j].x = vtx2->x; vtx_buf[j].y = vtx2->y; vtx_buf[j++].rhw = vtx2->rhw; } } vtxCount = j; if( vtxCount < 3 ) return 0; // vertical clip vtx2 = &vtx_buf[vtxCount-1]; j = 0; for( i = 0; i < vtxCount; ++i ) { vtx1 = vtx2; vtx2 = &vtx_buf[i]; if( vtx1->y < FltWinTop ) { if( vtx2->y < FltWinTop ) { continue; } clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; vtx[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else if( vtx1->y > FltWinBottom ) { if( vtx2->y > FltWinBottom ) { continue; } clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; vtx[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } if( vtx2->y < FltWinTop ) { clip = (FltWinTop - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinTop; vtx[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else if( vtx2->y > FltWinBottom ) { clip = (FltWinBottom - vtx2->y) / (vtx1->y - vtx2->y); vtx[j].x = vtx2->x + (vtx1->x - vtx2->x) * clip; vtx[j].y = FltWinBottom; vtx[j++].rhw = vtx2->rhw + (vtx1->rhw - vtx2->rhw) * clip; } else { vtx[j].x = vtx2->x; vtx[j].y = vtx2->y; vtx[j++].rhw = vtx2->rhw; } } return ( j < 3 ) ? 0 : j; } void __cdecl InsertTrans8(PHD_VBUF *vbuf, __int16 shade) { int i, nPoints, polyZ; char clipOR = 0x00; char clipAND = 0xFF; #ifdef FEATURE_VIDEOFX_IMPROVED int nVtx = ( ShadowMode == 1 ) ? 32 : 8; #else // FEATURE_VIDEOFX_IMPROVED int nVtx = 8; #endif // FEATURE_VIDEOFX_IMPROVED for( i = 0; i < nVtx; ++i ) { clipOR |= LOBYTE(vbuf[i].clip); clipAND &= LOBYTE(vbuf[i].clip); } if( (clipOR < 0) || (clipAND != 0) || !VBUF_VISIBLE(vbuf[0], vbuf[1], vbuf[2]) ) return; for( i = 0; i < nVtx; ++i ) { VBuffer[i].x = vbuf[i].xs; VBuffer[i].y = vbuf[i].ys; } nPoints = nVtx; if( clipOR != 0 ) { FltWinLeft = 0.0; FltWinTop = 0.0; FltWinRight = (float)PhdWinMaxX; FltWinBottom = (float)PhdWinMaxY; nPoints = XYClipper(nPoints, VBuffer); if( nPoints == 0) return; } #ifdef FEATURE_VIDEOFX_IMPROVED double polyZflt = 0.0; for( i = 0; i < nVtx; ++i ) { polyZflt += (double)vbuf[i].zv / (double)nVtx; } polyZ = polyZflt; #else // FEATURE_VIDEOFX_IMPROVED polyZ = 0; for( i = 0; i < nVtx; ++i ) { polyZ += vbuf[i].zv; } polyZ /= nVtx; #endif // FEATURE_VIDEOFX_IMPROVED Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(polyZ); ++Sort3dPtr; *(Info3dPtr++) = POLY_trans; *(Info3dPtr++) = shade; *(Info3dPtr++) = nPoints; // number of vertices for( i = 0; i < nPoints; ++i ) { *(Info3dPtr++) = (int)VBuffer[i].x; *(Info3dPtr++) = (int)VBuffer[i].y; } ++SurfaceCount; } void __cdecl InsertTransQuad(int x, int y, int width, int height, int z) { Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(PhdNearZ + 8*z); ++Sort3dPtr; *(Info3dPtr++) = POLY_trans; // NOTE: Here 24 is DepthQ index (shade factor). // 0 lightest, 15 no shade, 31 darkest (pitch black). // But original code has value 32 supposed to be interpreted as 24 (which means 50% darker) // Also 32 is maximum valid value in the original code, though it is DepthQTable range violation. // This trick worked because DepthQIndex array was right after DepthQ array in the memory // (DepthQIndex is equal to &DepthQ[24].index).This allocation is not guaranteed on some systems, so it was fixed *(Info3dPtr++) = 24; *(Info3dPtr++) = 4; // number of vertices *(Info3dPtr++) = x; *(Info3dPtr++) = y; *(Info3dPtr++) = x + width; *(Info3dPtr++) = y; *(Info3dPtr++) = x + width; *(Info3dPtr++) = y + height; *(Info3dPtr++) = x; *(Info3dPtr++) = y + height; ++SurfaceCount; } void __cdecl InsertFlatRect(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_flat; *(Info3dPtr++) = colorIdx; *(Info3dPtr++) = 4; // number of vertices *(Info3dPtr++) = x0; *(Info3dPtr++) = y0; *(Info3dPtr++) = x1; *(Info3dPtr++) = y0; *(Info3dPtr++) = x1; *(Info3dPtr++) = y1; *(Info3dPtr++) = x0; *(Info3dPtr++) = y1; ++SurfaceCount; } void __cdecl InsertLine(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_line; *(Info3dPtr++) = PhdWinMinX + x0; *(Info3dPtr++) = PhdWinMinY + y0; *(Info3dPtr++) = PhdWinMinX + x1; *(Info3dPtr++) = PhdWinMinY + y1; *(Info3dPtr++) = colorIdx; ++SurfaceCount; } void __cdecl InsertGT3_ZBuffered(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_TEXTURE *texture, PHD_UV *uv0, PHD_UV *uv1, PHD_UV *uv2) { char clipOR, clipAND; POINT_INFO points[3]; int nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) return; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) return; if( clipOR == 0 ) { VBufferD3D[0].sx = vtx0->xs; VBufferD3D[0].sy = vtx0->ys; VBufferD3D[0].sz = FltResZBuf - FltResZORhw * vtx0->rhw; VBufferD3D[0].rhw = vtx0->rhw; VBufferD3D[0].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx0->g, true); VBufferD3D[0].tu = (double)uv0->u / (double)PHD_ONE; VBufferD3D[0].tv = (double)uv0->v / (double)PHD_ONE; VBufferD3D[1].sx = vtx1->xs; VBufferD3D[1].sy = vtx1->ys; VBufferD3D[1].sz = FltResZBuf - FltResZORhw * vtx1->rhw; VBufferD3D[1].rhw = vtx1->rhw; VBufferD3D[1].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx1->g, true); VBufferD3D[1].tu = (double)uv1->u / (double)PHD_ONE; VBufferD3D[1].tv = (double)uv1->v / (double)PHD_ONE; VBufferD3D[2].sx = vtx2->xs; VBufferD3D[2].sy = vtx2->ys; VBufferD3D[2].sz = FltResZBuf - FltResZORhw * vtx2->rhw; VBufferD3D[2].rhw = vtx2->rhw; VBufferD3D[2].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx2->g, true); VBufferD3D[2].tu = (double)uv2->u / (double)PHD_ONE; VBufferD3D[2].tv = (double)uv2->v / (double)PHD_ONE; #ifdef FEATURE_VIDEOFX_IMPROVED HWR_TexSource(texture->tpage == (UINT16)~0 ? GetEnvmapTextureHandle() : HWR_PageHandles[texture->tpage]); #else // !FEATURE_VIDEOFX_IMPROVED HWR_TexSource(HWR_PageHandles[texture->tpage]); #endif // !FEATURE_VIDEOFX_IMPROVED HWR_EnableColorKey(texture->drawtype != DRAW_Opaque); HWR_DrawPrimitive(D3DPT_TRIANGLELIST, VBufferD3D, 3, true); return; } VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (double)vtx0->g; VBuffer[0].u = (double)uv0->u * vtx0->rhw; VBuffer[0].v = (double)uv0->v * vtx0->rhw; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (double)vtx1->g; VBuffer[1].u = (double)uv1->u * vtx1->rhw; VBuffer[1].v = (double)uv1->v * vtx1->rhw; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (double)vtx2->g; VBuffer[2].u = (double)uv2->u * vtx2->rhw; VBuffer[2].v = (double)uv2->v * vtx2->rhw; } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) return; points[0].xv = vtx0->xv; points[0].yv = vtx0->yv; points[0].zv = vtx0->zv; points[0].rhw = vtx0->rhw; points[0].xs = vtx0->xs; points[0].ys = vtx0->ys; points[0].u = (float)uv0->u; points[0].v = (float)uv0->v; points[0].g = (float)vtx0->g; points[1].yv = vtx1->yv; points[1].xv = vtx1->xv; points[1].zv = vtx1->zv; points[1].rhw = vtx1->rhw; points[1].xs = vtx1->xs; points[1].ys = vtx1->ys; points[1].u = (float)uv1->u; points[1].v = (float)uv1->v; points[1].g = (float)vtx1->g; points[2].xv = vtx2->xv; points[2].yv = vtx2->yv; points[2].zv = vtx2->zv; points[2].rhw = vtx2->rhw; points[2].xs = vtx2->xs; points[2].ys = vtx2->ys; points[2].u = (float)uv2->u; points[2].v = (float)uv2->v; points[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, points, VBuffer); if( nPoints == 0 ) return; } nPoints = XYGUVClipper(nPoints, VBuffer); if( nPoints == 0 ) return; #ifdef FEATURE_VIDEOFX_IMPROVED HWR_TexSource(texture->tpage == (UINT16)~0 ? GetEnvmapTextureHandle() : HWR_PageHandles[texture->tpage]); #else // !FEATURE_VIDEOFX_IMPROVED HWR_TexSource(HWR_PageHandles[texture->tpage]); #endif // !FEATURE_VIDEOFX_IMPROVED HWR_EnableColorKey(texture->drawtype != DRAW_Opaque); DrawClippedPoly_Textured(nPoints); } void __cdecl DrawClippedPoly_Textured(int vtxCount) { D3DCOLOR color; double tu, tv; if( vtxCount == 0 ) return; for( int i = 0; i < vtxCount; ++i ) { color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, (DWORD)VBuffer[i].g, true); tu = VBuffer[i].u / VBuffer[i].rhw / (double)PHD_ONE; tv = VBuffer[i].v / VBuffer[i].rhw / (double)PHD_ONE; CLAMP(tu, 0.0, 1.0); CLAMP(tv, 0.0, 1.0); VBufferD3D[i].sx = VBuffer[i].x; VBufferD3D[i].sy = VBuffer[i].y; VBufferD3D[i].sz = FltResZBuf - FltResZORhw * VBuffer[i].rhw; VBufferD3D[i].rhw = VBuffer[i].rhw; VBufferD3D[i].color = color; VBufferD3D[i].tu = tu; VBufferD3D[i].tv = tv; } HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, VBufferD3D, vtxCount, true); } void __cdecl InsertGT4_ZBuffered(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_VBUF *vtx3, PHD_TEXTURE *texture) { char clipOR, clipAND; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) return; if( clipOR == 0 && VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) { VBufferD3D[0].sx = vtx0->xs; VBufferD3D[0].sy = vtx0->ys; VBufferD3D[0].sz = FltResZBuf - FltResZORhw * vtx0->rhw; VBufferD3D[0].rhw = vtx0->rhw; VBufferD3D[0].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx0->g, true); VBufferD3D[0].tu = (double)texture->uv[0].u / (double)PHD_ONE; VBufferD3D[0].tv = (double)texture->uv[0].v / (double)PHD_ONE; VBufferD3D[1].sx = vtx1->xs; VBufferD3D[1].sy = vtx1->ys; VBufferD3D[1].sz = FltResZBuf - FltResZORhw * vtx1->rhw; VBufferD3D[1].rhw = vtx1->rhw; VBufferD3D[1].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx1->g, true); VBufferD3D[1].tu = (double)texture->uv[1].u / (double)PHD_ONE; VBufferD3D[1].tv = (double)texture->uv[1].v / (double)PHD_ONE; VBufferD3D[2].sx = vtx2->xs; VBufferD3D[2].sy = vtx2->ys; VBufferD3D[2].sz = FltResZBuf - FltResZORhw * vtx2->rhw; VBufferD3D[2].rhw = vtx2->rhw; VBufferD3D[2].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx2->g, true); VBufferD3D[2].tu = (double)texture->uv[2].u / (double)PHD_ONE; VBufferD3D[2].tv = (double)texture->uv[2].v / (double)PHD_ONE; VBufferD3D[3].sx = vtx3->xs; VBufferD3D[3].sy = vtx3->ys; VBufferD3D[3].sz = FltResZBuf - FltResZORhw * vtx3->rhw; VBufferD3D[3].rhw = vtx3->rhw; VBufferD3D[3].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx3->g, true); VBufferD3D[3].tu = (double)texture->uv[3].u / (double)PHD_ONE; VBufferD3D[3].tv = (double)texture->uv[3].v / (double)PHD_ONE; #ifdef FEATURE_VIDEOFX_IMPROVED HWR_TexSource(texture->tpage == (UINT16)~0 ? GetEnvmapTextureHandle() : HWR_PageHandles[texture->tpage]); #else // !FEATURE_VIDEOFX_IMPROVED HWR_TexSource(HWR_PageHandles[texture->tpage]); #endif // !FEATURE_VIDEOFX_IMPROVED HWR_EnableColorKey(texture->drawtype != DRAW_Opaque); HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, VBufferD3D, 4, true); } else if( (clipOR < 0 && visible_zclip(vtx0, vtx1, vtx2)) || (clipOR > 0 && VBUF_VISIBLE(*vtx0, *vtx1, *vtx2)) ) { InsertGT3_ZBuffered(vtx0, vtx1, vtx2, texture, texture->uv, &texture->uv[1], &texture->uv[2]); InsertGT3_ZBuffered(vtx0, vtx2, vtx3, texture, texture->uv, &texture->uv[2], &texture->uv[3]); } } __int16 *__cdecl InsertObjectGT4_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType) { PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; PHD_TEXTURE *texture; for( int i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[ptrObj[0]]; vtx1 = &PhdVBuf[ptrObj[1]]; vtx2 = &PhdVBuf[ptrObj[2]]; vtx3 = &PhdVBuf[ptrObj[3]]; texture = &PhdTextureInfo[ptrObj[4]]; if( texture->drawtype != DRAW_Opaque ) InsertGT4_Sorted(vtx0, vtx1, vtx2, vtx3, texture, sortType); else InsertGT4_ZBuffered(vtx0, vtx1, vtx2, vtx3, texture); ptrObj += 5; } return ptrObj; } __int16 *__cdecl InsertObjectGT3_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType) { PHD_VBUF *vtx0, *vtx1, *vtx2; PHD_TEXTURE *texture; PHD_UV *uv; for( int i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[ptrObj[0]]; vtx1 = &PhdVBuf[ptrObj[1]]; vtx2 = &PhdVBuf[ptrObj[2]]; texture = &PhdTextureInfo[ptrObj[3]]; uv = texture->uv; if( texture->drawtype != DRAW_Opaque ) InsertGT3_Sorted(vtx0, vtx1, vtx2, texture, &uv[0], &uv[1], &uv[2], sortType); else InsertGT3_ZBuffered(vtx0, vtx1, vtx2, texture, &uv[0], &uv[1], &uv[2]); ptrObj += 4; } return ptrObj; } __int16 *__cdecl InsertObjectG4_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; int i, nPoints; __int16 colorIdx; POINT_INFO pts[4]; HWR_TexSource(0); HWR_EnableColorKey(false); for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; vtx3 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 4; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; VBuffer[3].x = vtx3->xs; VBuffer[3].y = vtx3->ys; VBuffer[3].rhw = vtx3->rhw; VBuffer[3].g = (float)vtx3->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; pts[3].xv = vtx3->xv; pts[3].yv = vtx3->yv; pts[3].zv = vtx3->zv; pts[3].rhw = vtx3->rhw; pts[3].xs = vtx3->xs; pts[3].ys = vtx3->ys; pts[3].g = (float)vtx3->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints != 0 ) { PALETTEENTRY *color = &GamePalette16[colorIdx >> 8]; #ifdef FEATURE_VIDEOFX_IMPROVED if( AlphaBlendMode && color->peFlags > 0 && color->peFlags <= 4 ) { float zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); short blend[4] = {POLY_HWR_half, POLY_HWR_add, POLY_HWR_sub, POLY_HWR_qrt}; InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, blend[color->peFlags - 1]); } else { DrawPoly_Gouraud(nPoints, color->peRed, color->peGreen, color->peBlue); } #else // FEATURE_VIDEOFX_IMPROVED DrawPoly_Gouraud(nPoints, color->peRed, color->peGreen, color->peBlue); #endif // FEATURE_VIDEOFX_IMPROVED } } return ptrObj; } void __cdecl DrawPoly_Gouraud(int vtxCount, int red, int green, int blue) { D3DCOLOR color; if( vtxCount == 0 ) return; for( int i = 0; i < vtxCount; ++i ) { color = shadeColor(red, green, blue, 0xFF, (DWORD)VBuffer[i].g, false); VBufferD3D[i].sx = VBuffer[i].x; VBufferD3D[i].sy = VBuffer[i].y; VBufferD3D[i].sz = FltResZBuf - FltResZORhw * VBuffer[i].rhw; VBufferD3D[i].rhw = VBuffer[i].rhw; VBufferD3D[i].color = color; } HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, VBufferD3D, vtxCount, true); } __int16 *__cdecl InsertObjectG3_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2; int i, nPoints; __int16 colorIdx; POINT_INFO pts[3]; HWR_TexSource(0); HWR_EnableColorKey(false); for( i = 0; i < number; ++i ) { vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints != 0 ) { PALETTEENTRY *color = &GamePalette16[colorIdx >> 8]; #ifdef FEATURE_VIDEOFX_IMPROVED if( AlphaBlendMode && color->peFlags > 0 && color->peFlags <= 4 ) { float zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); short blend[4] = {POLY_HWR_half, POLY_HWR_add, POLY_HWR_sub, POLY_HWR_qrt}; InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, blend[color->peFlags - 1]); } else { DrawPoly_Gouraud(nPoints, color->peRed, color->peGreen, color->peBlue); } #else // FEATURE_VIDEOFX_IMPROVED DrawPoly_Gouraud(nPoints, color->peRed, color->peGreen, color->peBlue); #endif // FEATURE_VIDEOFX_IMPROVED } } return ptrObj; } void __cdecl InsertFlatRect_ZBuffered(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { double sz, rhw; D3DCOLOR color; if( x0 >= x1 || y0 >= y1 ) return; if( x0 < PhdWinMinX ) x0 = PhdWinMinX; if( y0 < PhdWinMinY ) y0 = PhdWinMinY; if( x1 > PhdWinMinX + PhdWinWidth ) x1 = PhdWinMinX + PhdWinWidth; if( y1 > PhdWinMinY + PhdWinHeight ) x1 = PhdWinMinY + PhdWinHeight; CLAMP(z, PhdNearZ, PhdFarZ); color = shadeColor(GamePalette8[colorIdx].red, GamePalette8[colorIdx].green, GamePalette8[colorIdx].blue, 0xFF, 0, false); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; VBufferD3D[0].sx = (float)x0; VBufferD3D[0].sy = (float)y0; VBufferD3D[1].sx = (float)x1; VBufferD3D[1].sy = (float)y0; VBufferD3D[2].sx = (float)x0; VBufferD3D[2].sy = (float)y1; VBufferD3D[3].sx = (float)x1; VBufferD3D[3].sy = (float)y1; for( int i=0; i<4; ++i ) { VBufferD3D[i].sz = sz; VBufferD3D[i].rhw = rhw; VBufferD3D[i].color = color; } HWR_TexSource(0); HWR_EnableColorKey(false); HWR_DrawPrimitive(D3DPT_TRIANGLESTRIP, VBufferD3D, 4, true); } void __cdecl InsertLine_ZBuffered(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { double sz, rhw; D3DCOLOR color; if( z > PhdFarZ ) { return; } if( z < PhdNearZ ) { z = PhdNearZ; } color = shadeColor(GamePalette8[colorIdx].red, GamePalette8[colorIdx].green, GamePalette8[colorIdx].blue, 0xFF, 0, false); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; VBufferD3D[0].sx = (float)(PhdWinMinX + x0); VBufferD3D[0].sy = (float)(PhdWinMinY + y0); VBufferD3D[1].sx = (float)(PhdWinMinX + x1); VBufferD3D[1].sy = (float)(PhdWinMinY + y1); for( int i=0; i<2; ++i ) { VBufferD3D[i].sz = sz; VBufferD3D[i].rhw = rhw; VBufferD3D[i].color = color; } HWR_TexSource(0); HWR_EnableColorKey(false); HWR_DrawPrimitive(D3DPT_LINESTRIP, VBufferD3D, 2, true); } void __cdecl InsertGT3_Sorted(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_TEXTURE *texture, PHD_UV *uv0, PHD_UV *uv1, PHD_UV *uv2, SORTTYPE sortType) { char clipOR, clipAND; float zv; POINT_INFO points[3]; int nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) return; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) return; if( clipOR == 0 ) { zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; #ifdef FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = GetPolyType(texture->drawtype); #else // FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_HWR_GTmap : POLY_HWR_WGTmap; #endif // FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 3; *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); HWR_VertexPtr[0].sx = vtx0->xs; HWR_VertexPtr[0].sy = vtx0->ys; HWR_VertexPtr[0].sz = FltResZBuf - FltResZORhw * vtx0->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[0].rhw = vtx0->rhw; HWR_VertexPtr[0].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx0->g, true); HWR_VertexPtr[0].tu = (double)uv0->u / (double)PHD_ONE; HWR_VertexPtr[0].tv = (double)uv0->v / (double)PHD_ONE; HWR_VertexPtr[1].sx = vtx1->xs; HWR_VertexPtr[1].sy = vtx1->ys; HWR_VertexPtr[1].sz = FltResZBuf - FltResZORhw * vtx1->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[1].rhw = vtx1->rhw; HWR_VertexPtr[1].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx1->g, true); HWR_VertexPtr[1].tu = (double)uv1->u / (double)PHD_ONE; HWR_VertexPtr[1].tv = (double)uv1->v / (double)PHD_ONE; HWR_VertexPtr[2].sx = vtx2->xs; HWR_VertexPtr[2].sy = vtx2->ys; HWR_VertexPtr[2].sz = FltResZBuf - FltResZORhw * vtx2->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[2].rhw = vtx2->rhw; HWR_VertexPtr[2].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx2->g, true); HWR_VertexPtr[2].tu = (double)uv2->u / (double)PHD_ONE; HWR_VertexPtr[2].tv = (double)uv2->v / (double)PHD_ONE; HWR_VertexPtr += 3; ++SurfaceCount; return; } VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (double)vtx0->g; VBuffer[0].u = (double)uv0->u * vtx0->rhw; VBuffer[0].v = (double)uv0->v * vtx0->rhw; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (double)vtx1->g; VBuffer[1].u = (double)uv1->u * vtx1->rhw; VBuffer[1].v = (double)uv1->v * vtx1->rhw; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (double)vtx2->g; VBuffer[2].u = (double)uv2->u * vtx2->rhw; VBuffer[2].v = (double)uv2->v * vtx2->rhw; } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) return; points[0].xv = vtx0->xv; points[0].yv = vtx0->yv; points[0].zv = vtx0->zv; points[0].rhw = vtx0->rhw; points[0].xs = vtx0->xs; points[0].ys = vtx0->ys; points[0].u = (float)uv0->u; points[0].v = (float)uv0->v; points[0].g = (float)vtx0->g; points[1].yv = vtx1->yv; points[1].xv = vtx1->xv; points[1].zv = vtx1->zv; points[1].rhw = vtx1->rhw; points[1].xs = vtx1->xs; points[1].ys = vtx1->ys; points[1].u = (float)uv1->u; points[1].v = (float)uv1->v; points[1].g = (float)vtx1->g; points[2].xv = vtx2->xv; points[2].yv = vtx2->yv; points[2].zv = vtx2->zv; points[2].rhw = vtx2->rhw; points[2].xs = vtx2->xs; points[2].ys = vtx2->ys; points[2].u = (float)uv2->u; points[2].v = (float)uv2->v; points[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, points, VBuffer); if( nPoints == 0 ) return; } nPoints = XYGUVClipper(nPoints, VBuffer); if( nPoints == 0 ) return; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); #ifdef FEATURE_VIDEOFX_IMPROVED InsertClippedPoly_Textured(nPoints, zv, GetPolyType(texture->drawtype), texture->tpage); #else // FEATURE_VIDEOFX_IMPROVED InsertClippedPoly_Textured(nPoints, zv, ( texture->drawtype == DRAW_Opaque ) ? POLY_HWR_GTmap : POLY_HWR_WGTmap, texture->tpage); #endif // FEATURE_VIDEOFX_IMPROVED } void __cdecl InsertClippedPoly_Textured(int vtxCount, float z, __int16 polyType, __int16 texPage) { double tu, tv; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = polyType; *(Info3dPtr++) = texPage; *(Info3dPtr++) = vtxCount; *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); for( int i = 0; i < vtxCount; ++i ) { tu = VBuffer[i].u / double(PHD_ONE) / VBuffer[i].rhw; tv = VBuffer[i].v / double(PHD_ONE) / VBuffer[i].rhw; CLAMP(tu, 0.0, 1.0); CLAMP(tv, 0.0, 1.0); HWR_VertexPtr[i].sx = VBuffer[i].x; HWR_VertexPtr[i].sy = VBuffer[i].y; HWR_VertexPtr[i].sz = FltResZBuf - FltResZORhw * VBuffer[i].rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[i].rhw = VBuffer[i].rhw; HWR_VertexPtr[i].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, VBuffer[i].g, true); HWR_VertexPtr[i].tu = tu; HWR_VertexPtr[i].tv = tv; } HWR_VertexPtr += vtxCount; ++SurfaceCount; } void __cdecl InsertGT4_Sorted(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_VBUF *vtx3, PHD_TEXTURE *texture, SORTTYPE sortType) { char clipOR, clipAND; float zv; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) return; if( clipOR == 0 && VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) { zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(zv); ++Sort3dPtr; #ifdef FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = GetPolyType(texture->drawtype); #else // FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = ( texture->drawtype == DRAW_Opaque ) ? POLY_HWR_GTmap : POLY_HWR_WGTmap; #endif // FEATURE_VIDEOFX_IMPROVED *Info3dPtr++ = texture->tpage; *Info3dPtr++ = 4; *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); HWR_VertexPtr[0].sx = vtx0->xs; HWR_VertexPtr[0].sy = vtx0->ys; HWR_VertexPtr[0].sz = FltResZBuf - FltResZORhw * vtx0->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[0].rhw = vtx0->rhw; HWR_VertexPtr[0].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx0->g, true); HWR_VertexPtr[0].tu = (double)texture->uv[0].u / (double)PHD_ONE; HWR_VertexPtr[0].tv = (double)texture->uv[0].v / (double)PHD_ONE; HWR_VertexPtr[1].sx = vtx1->xs; HWR_VertexPtr[1].sy = vtx1->ys; HWR_VertexPtr[1].sz = FltResZBuf - FltResZORhw * vtx1->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[1].rhw = vtx1->rhw; HWR_VertexPtr[1].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx1->g, true); HWR_VertexPtr[1].tu = (double)texture->uv[1].u / (double)PHD_ONE; HWR_VertexPtr[1].tv = (double)texture->uv[1].v / (double)PHD_ONE; HWR_VertexPtr[2].sx = vtx2->xs; HWR_VertexPtr[2].sy = vtx2->ys; HWR_VertexPtr[2].sz = FltResZBuf - FltResZORhw * vtx2->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[2].rhw = vtx2->rhw; HWR_VertexPtr[2].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx2->g, true); HWR_VertexPtr[2].tu = (double)texture->uv[2].u / (double)PHD_ONE; HWR_VertexPtr[2].tv = (double)texture->uv[2].v / (double)PHD_ONE; HWR_VertexPtr[3].sx = vtx3->xs; HWR_VertexPtr[3].sy = vtx3->ys; HWR_VertexPtr[3].sz = FltResZBuf - FltResZORhw * vtx3->rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[3].rhw = vtx3->rhw; HWR_VertexPtr[3].color = shadeColor(0xFF, 0xFF, 0xFF, 0xFF, vtx3->g, true); HWR_VertexPtr[3].tu = (double)texture->uv[3].u / (double)PHD_ONE; HWR_VertexPtr[3].tv = (double)texture->uv[3].v / (double)PHD_ONE; HWR_VertexPtr += 4; ++SurfaceCount; } else if( (clipOR < 0 && visible_zclip(vtx0, vtx1, vtx2)) || (clipOR > 0 && VBUF_VISIBLE(*vtx0, *vtx1, *vtx2)) ) { InsertGT3_Sorted(vtx0, vtx1, vtx2, texture, texture->uv, &texture->uv[1], &texture->uv[2], sortType); InsertGT3_Sorted(vtx0, vtx2, vtx3, texture, texture->uv, &texture->uv[2], &texture->uv[3], sortType); } } __int16 *__cdecl InsertObjectGT4_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType) { PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; PHD_TEXTURE *texture; for( int i = 0; i < number; ++i ) { if( HWR_VertexBufferFull() ) { ptrObj += (number - i) * 5; break; } vtx0 = &PhdVBuf[ptrObj[0]]; vtx1 = &PhdVBuf[ptrObj[1]]; vtx2 = &PhdVBuf[ptrObj[2]]; vtx3 = &PhdVBuf[ptrObj[3]]; texture = &PhdTextureInfo[ptrObj[4]]; ptrObj += 5; InsertGT4_Sorted(vtx0, vtx1, vtx2, vtx3, texture, sortType); } return ptrObj; } __int16 *__cdecl InsertObjectGT3_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType) { PHD_VBUF *vtx0, *vtx1, *vtx2; PHD_TEXTURE *texture; PHD_UV *uv; for( int i = 0; i < number; ++i ) { if( HWR_VertexBufferFull() ) { ptrObj += (number - i) * 4; break; } vtx0 = &PhdVBuf[ptrObj[0]]; vtx1 = &PhdVBuf[ptrObj[1]]; vtx2 = &PhdVBuf[ptrObj[2]]; texture = &PhdTextureInfo[ptrObj[3]]; uv = texture->uv; ptrObj += 4; InsertGT3_Sorted(vtx0, vtx1, vtx2, texture, &uv[0], &uv[1], &uv[2], sortType); } return ptrObj; } __int16 *__cdecl InsertObjectG4_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2, *vtx3; int i, nPoints; float zv; __int16 colorIdx; PALETTEENTRY *color; POINT_INFO pts[4]; for( i = 0; i < number; ++i ) { if( HWR_VertexBufferFull() ) { ptrObj += number - i; break; } vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; vtx3 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 4; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip | vtx3->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip & vtx3->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; VBuffer[3].x = vtx3->xs; VBuffer[3].y = vtx3->ys; VBuffer[3].rhw = vtx3->rhw; VBuffer[3].g = (float)vtx3->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; pts[3].xv = vtx3->xv; pts[3].yv = vtx3->yv; pts[3].zv = vtx3->zv; pts[3].rhw = vtx3->rhw; pts[3].xs = vtx3->xs; pts[3].ys = vtx3->ys; pts[3].g = (float)vtx3->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints == 0 ) continue; color = &GamePalette16[colorIdx >> 8]; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv, vtx3->zv); #ifdef FEATURE_VIDEOFX_IMPROVED if( AlphaBlendMode && color->peFlags > 0 && color->peFlags <= 4 ) { short blend[4] = {POLY_HWR_half, POLY_HWR_add, POLY_HWR_sub, POLY_HWR_qrt}; InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, blend[color->peFlags - 1]); } else { InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, POLY_HWR_gouraud); } #else // FEATURE_VIDEOFX_IMPROVED InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, POLY_HWR_gouraud); #endif // FEATURE_VIDEOFX_IMPROVED } return ptrObj; } void __cdecl InsertPoly_Gouraud(int vtxCount, float z, int red, int green, int blue, __int16 polyType) { BYTE alpha = ( polyType == POLY_HWR_trans ) ? 0x80 : 0xFF; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = polyType; *(Info3dPtr++) = vtxCount; *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); for( int i = 0; i < vtxCount; ++i ) { HWR_VertexPtr[i].sx = VBuffer[i].x; HWR_VertexPtr[i].sy = VBuffer[i].y; HWR_VertexPtr[i].sz = FltResZBuf - FltResZORhw * VBuffer[i].rhw; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[i].rhw = VBuffer[i].rhw; HWR_VertexPtr[i].color = shadeColor(red, green, blue, alpha, VBuffer[i].g, false); } HWR_VertexPtr += vtxCount; ++SurfaceCount; } __int16 *__cdecl InsertObjectG3_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType) { char clipOR, clipAND; PHD_VBUF *vtx0, *vtx1, *vtx2; int i, nPoints; float zv; __int16 colorIdx; PALETTEENTRY *color; POINT_INFO pts[3]; for( i = 0; i < number; ++i ) { if( HWR_VertexBufferFull() ) { ptrObj += number - i; break; } vtx0 = &PhdVBuf[*ptrObj++]; vtx1 = &PhdVBuf[*ptrObj++]; vtx2 = &PhdVBuf[*ptrObj++]; colorIdx = *ptrObj++; nPoints = 3; clipOR = LOBYTE(vtx0->clip | vtx1->clip | vtx2->clip); clipAND = LOBYTE(vtx0->clip & vtx1->clip & vtx2->clip); if( clipAND != 0 ) continue; if( clipOR >= 0 ) { if( !VBUF_VISIBLE(*vtx0, *vtx1, *vtx2) ) continue; VBuffer[0].x = vtx0->xs; VBuffer[0].y = vtx0->ys; VBuffer[0].rhw = vtx0->rhw; VBuffer[0].g = (float)vtx0->g; VBuffer[1].x = vtx1->xs; VBuffer[1].y = vtx1->ys; VBuffer[1].rhw = vtx1->rhw; VBuffer[1].g = (float)vtx1->g; VBuffer[2].x = vtx2->xs; VBuffer[2].y = vtx2->ys; VBuffer[2].rhw = vtx2->rhw; VBuffer[2].g = (float)vtx2->g; if( clipOR > 0 ) { nPoints = XYGClipper(nPoints, VBuffer); } } else { if( !visible_zclip(vtx0, vtx1, vtx2) ) continue; pts[0].xv = vtx0->xv; pts[0].yv = vtx0->yv; pts[0].zv = vtx0->zv; pts[0].rhw = vtx0->rhw; pts[0].xs = vtx0->xs; pts[0].ys = vtx0->ys; pts[0].g = (float)vtx0->g; pts[1].xv = vtx1->xv; pts[1].yv = vtx1->yv; pts[1].zv = vtx1->zv; pts[1].rhw = vtx1->rhw; pts[1].xs = vtx1->xs; pts[1].ys = vtx1->ys; pts[1].g = (float)vtx1->g; pts[2].xv = vtx2->xv; pts[2].yv = vtx2->yv; pts[2].zv = vtx2->zv; pts[2].rhw = vtx2->rhw; pts[2].xs = vtx2->xs; pts[2].ys = vtx2->ys; pts[2].g = (float)vtx2->g; nPoints = ZedClipper(nPoints, pts, VBuffer); if( nPoints == 0 ) continue; nPoints = XYGClipper(nPoints, VBuffer); } if( nPoints == 0 ) continue; color = &GamePalette16[colorIdx >> 8]; zv = CalculatePolyZ(sortType, vtx0->zv, vtx1->zv, vtx2->zv); #ifdef FEATURE_VIDEOFX_IMPROVED if( AlphaBlendMode && color->peFlags > 0 && color->peFlags <= 4 ) { short blend[4] = {POLY_HWR_half, POLY_HWR_add, POLY_HWR_sub, POLY_HWR_qrt}; InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, blend[color->peFlags - 1]); } else { InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, POLY_HWR_gouraud); } #else // FEATURE_VIDEOFX_IMPROVED InsertPoly_Gouraud(nPoints, zv, color->peRed, color->peGreen, color->peBlue, POLY_HWR_gouraud); #endif // FEATURE_VIDEOFX_IMPROVED } return ptrObj; } #ifdef FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade, DWORD flags) { if( TextureFormat.bpp < 16 && CHK_ANY(flags, SPR_TINT) ) return; // tinted sprites are not supported for 8 bit textured mode #else // FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade) { #endif // FEATURE_VIDEOFX_IMPROVED double rhw, u0, v0, u1, v1; int uOffset, vOffset, nPoints; if( HWR_VertexBufferFull() || x0 >= x1 || y0 >= y1 || x1 <= 0 || y1 <= 0 || x0 >= PhdWinMaxX || y0 >= PhdWinMaxY || z >= PhdFarZ ) return; x0 += PhdWinMinX; y0 += PhdWinMinY; x1 += PhdWinMinX; y1 += PhdWinMinY; if( z < PhdNearZ ) z = PhdNearZ; rhw = RhwFactor / (double)z; uOffset = LOBYTE(PhdSpriteInfo[spriteIdx].offset) * 256; vOffset = HIBYTE(PhdSpriteInfo[spriteIdx].offset) * 256; // NOTE: page side is not counted in the original game, but we need it for HD textures int adjustment = UvAdd * 256 / GetTextureSideByPage(PhdSpriteInfo[spriteIdx].texPage); #if (DIRECT3D_VERSION >= 0x900) double forcedAdjust = GetTexPagesAdjustment(); if( forcedAdjust > 0.0) { adjustment = (int)(forcedAdjust * 256.0); } #endif // (DIRECT3D_VERSION >= 0x900) #ifdef FEATURE_HUD_IMPROVED if( spriteIdx >= (int)ARRAY_SIZE(PhdSpriteInfo) - HUD_SPRITE_RESERVED ) { adjustment = 0; } #endif // FEATURE_HUD_IMPROVED CLAMPL(adjustment, 1); u0 = rhw * (double)(uOffset - adjustment + PhdSpriteInfo[spriteIdx].width); v0 = rhw * (double)(vOffset + adjustment); u1 = rhw * (double)(uOffset + adjustment); v1 = rhw * (double)(vOffset - adjustment + PhdSpriteInfo[spriteIdx].height); VBuffer[0].x = (float)x0; VBuffer[0].y = (float)y0; VBuffer[0].u = u1; VBuffer[0].v = v0; VBuffer[1].x = (float)x1; VBuffer[1].y = (float)y0; VBuffer[1].u = u0; VBuffer[1].v = v0; VBuffer[2].x = (float)x1; VBuffer[2].y = (float)y1; VBuffer[2].u = u0; VBuffer[2].v = v1; VBuffer[3].x = (float)x0; VBuffer[3].y = (float)y1; VBuffer[3].u = u1; VBuffer[3].v = v1; for( int i=0; i<4; ++i ) { VBuffer[i].rhw = rhw; VBuffer[i].g = (float)shade; } nPoints = 4; if( x0 < PhdWinMinX || y0 < PhdWinMinY || x1 > PhdWinWidth + PhdWinMinX || y1 > PhdWinHeight + PhdWinMinY ) { FltWinLeft = (float)PhdWinMinX; FltWinTop = (float)PhdWinMinY; FltWinRight = (float)(PhdWinMinX + PhdWinWidth); FltWinBottom = (float)(PhdWinMinY + PhdWinHeight); nPoints = XYGUVClipper(nPoints, VBuffer); if( nPoints == 0 ) return; } bool isShadeEffectBackup = IsShadeEffect; IsShadeEffect = false; #ifdef FEATURE_VIDEOFX_IMPROVED short polyType = POLY_HWR_WGTmap; if( CHK_ANY(flags, SPR_TINT) ) { GlobalTint = RGBA_SETALPHA(flags, 0xFF); } if( AlphaBlendMode && CHK_ANY(flags, SPR_SEMITRANS) ) { short blend[4] = { POLY_HWR_WGTmapHalf, POLY_HWR_WGTmapAdd, POLY_HWR_WGTmapSub, POLY_HWR_WGTmapQrt, }; polyType = blend[(flags & SPR_BLEND) >> 29]; } InsertClippedPoly_Textured(nPoints, (float)z, polyType, PhdSpriteInfo[spriteIdx].texPage); GlobalTint = 0; #else // FEATURE_VIDEOFX_IMPROVED InsertClippedPoly_Textured(nPoints, (float)z, POLY_HWR_WGTmap, PhdSpriteInfo[spriteIdx].texPage); #endif // FEATURE_VIDEOFX_IMPROVED IsShadeEffect = isShadeEffectBackup; } void __cdecl InsertFlatRect_Sorted(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { double rhw, sz; D3DCOLOR color; if( x0 >= x1 || y0 >= y1 ) return; if( x0 < PhdWinMinX ) x0 = PhdWinMinX; if( y0 < PhdWinMinY ) y0 = PhdWinMinY; if( x1 > PhdWinMinX + PhdWinWidth ) x1 = PhdWinMinX + PhdWinWidth; if( y1 > PhdWinMinY + PhdWinHeight ) x1 = PhdWinMinY + PhdWinHeight; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_HWR_gouraud; *(Info3dPtr++) = 4; // vertex count *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); color = shadeColor(GamePalette8[colorIdx].red, GamePalette8[colorIdx].green, GamePalette8[colorIdx].blue, 0xFF, 0, false); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; HWR_VertexPtr[0].sx = (float)x0; HWR_VertexPtr[0].sy = (float)y0; HWR_VertexPtr[1].sx = (float)x1; HWR_VertexPtr[1].sy = (float)y0; HWR_VertexPtr[2].sx = (float)x1; HWR_VertexPtr[2].sy = (float)y1; HWR_VertexPtr[3].sx = (float)x0; HWR_VertexPtr[3].sy = (float)y1; for( int i=0; i<4; ++i ) { HWR_VertexPtr[i].color = color; HWR_VertexPtr[i].sz = sz; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[i].rhw = rhw; } HWR_VertexPtr += 4; ++SurfaceCount; } void __cdecl InsertLine_Sorted(int x0, int y0, int x1, int y1, int z, BYTE colorIdx) { double rhw, sz; D3DCOLOR color; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_HWR_line; *(Info3dPtr++) = 2; // vertex count *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); color = shadeColor(GamePalette8[colorIdx].red, GamePalette8[colorIdx].green, GamePalette8[colorIdx].blue, 0xFF, 0, false); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; HWR_VertexPtr[0].sx = (float)(PhdWinMinX + x0); HWR_VertexPtr[0].sy = (float)(PhdWinMinY + y0); HWR_VertexPtr[1].sx = (float)(PhdWinMinX + x1); HWR_VertexPtr[1].sy = (float)(PhdWinMinY + y1); for( int i=0; i<2; ++i ) { HWR_VertexPtr[i].color = color; HWR_VertexPtr[i].sz = sz; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[i].rhw = rhw; } HWR_VertexPtr += 2; ++SurfaceCount; } void __cdecl InsertTrans8_Sorted(PHD_VBUF *vbuf, __int16 shade) { int i, nPoints, polyZ; char clipOR = 0x00; char clipAND = 0xFF; #ifdef FEATURE_VIDEOFX_IMPROVED int nVtx = ( ShadowMode == 1 ) ? 32 : 8; #else // FEATURE_VIDEOFX_IMPROVED int nVtx = 8; #endif // FEATURE_VIDEOFX_IMPROVED for( i = 0; i < nVtx; ++i ) { clipOR |= LOBYTE(vbuf[i].clip); clipAND &= LOBYTE(vbuf[i].clip); } if( (clipOR < 0) || (clipAND != 0) || !VBUF_VISIBLE(vbuf[0], vbuf[1], vbuf[2]) ) return; for( i = 0; i < nVtx; ++i ) { VBuffer[i].x = vbuf[i].xs; VBuffer[i].y = vbuf[i].ys; VBuffer[i].rhw = RhwFactor / (double)(vbuf[i].zv - 0x20000); } nPoints = nVtx; if( clipOR != 0 ) { FltWinLeft = 0.0; FltWinTop = 0.0; FltWinRight = (float)PhdWinMaxX; FltWinBottom = (float)PhdWinMaxY; nPoints = XYClipper(nPoints, VBuffer); if( nPoints == 0) return; } #ifdef FEATURE_VIDEOFX_IMPROVED double polyZflt = 0.0; for( i = 0; i < nVtx; ++i ) { polyZflt += (double)vbuf[i].zv / (double)nVtx; } polyZ = polyZflt; #else // FEATURE_VIDEOFX_IMPROVED polyZ = 0; for( i = 0; i < nVtx; ++i ) { polyZ += vbuf[i].zv; } polyZ /= nVtx; #endif // FEATURE_VIDEOFX_IMPROVED InsertPoly_Gouraud(nPoints, (float)(polyZ - 0x20000), 0, 0, 0, POLY_HWR_trans); } void __cdecl InsertTransQuad_Sorted(int x, int y, int width, int height, int z) { float x0, y0, x1, y1; double rhw, sz; Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_HWR_trans; *(Info3dPtr++) = 4; // vertex count *(D3DTLVERTEX **)Info3dPtr = HWR_VertexPtr; Info3dPtr += sizeof(D3DTLVERTEX *)/sizeof(__int16); x0 = (float)x; y0 = (float)y; x1 = (float)(x + width); y1 = (float)(y + height); rhw = RhwFactor / (double)z; sz = FltResZBuf - rhw * FltResZORhw; HWR_VertexPtr[0].sx = x0; HWR_VertexPtr[0].sy = y0; HWR_VertexPtr[1].sx = x1; HWR_VertexPtr[1].sy = y0; HWR_VertexPtr[2].sx = x1; HWR_VertexPtr[2].sy = y1; HWR_VertexPtr[3].sx = x0; HWR_VertexPtr[3].sy = y1; for( int i=0; i<4; ++i ) { HWR_VertexPtr[i].color = 0x80000000; // half transparent black HWR_VertexPtr[i].sz = sz; // NOTE: there was bug because of uninitialized sz and rhw HWR_VertexPtr[i].rhw = rhw; } HWR_VertexPtr += 4; ++SurfaceCount; } #ifdef FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade, DWORD flags) { if( CHK_ANY(flags, SPR_TINT) ) return; // tinted sprites are not supported by software renderer yet #else // FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade) { #endif // FEATURE_VIDEOFX_IMPROVED Sort3dPtr->_0 = (DWORD)Info3dPtr; Sort3dPtr->_1 = MAKE_ZSORT(z); ++Sort3dPtr; *(Info3dPtr++) = POLY_sprite; *(Info3dPtr++) = x0; *(Info3dPtr++) = y0; *(Info3dPtr++) = x1; *(Info3dPtr++) = y1; *(Info3dPtr++) = spriteIdx; *(Info3dPtr++) = shade; ++SurfaceCount; } /* * Inject function */ void Inject_3Dinsert() { INJECT(0x00405840, visible_zclip); INJECT(0x004058B0, ZedClipper); INJECT(0x004059F0, XYGUVClipper); INJECT(0x00405F10, InsertObjectGT4); INJECT(0x00406970, InsertObjectGT3); INJECT(0x004071F0, XYGClipper); INJECT(0x00407620, InsertObjectG4); INJECT(0x00407A00, InsertObjectG3); INJECT(0x00407D20, XYClipper); INJECT(0x00407FF0, InsertTrans8); INJECT(0x004084A0, InsertTransQuad); INJECT(0x00408580, InsertFlatRect); INJECT(0x00408650, InsertLine); INJECT(0x00408710, InsertGT3_ZBuffered); INJECT(0x00408D60, DrawClippedPoly_Textured); INJECT(0x00408EA0, InsertGT4_ZBuffered); INJECT(0x004092E0, InsertObjectGT4_ZBuffered); INJECT(0x00409380, InsertObjectGT3_ZBuffered); INJECT(0x00409430, InsertObjectG4_ZBuffered); INJECT(0x004097D0, DrawPoly_Gouraud); INJECT(0x004098D0, InsertObjectG3_ZBuffered); INJECT(0x00409BB0, InsertFlatRect_ZBuffered); INJECT(0x00409D80, InsertLine_ZBuffered); INJECT(0x00409EC0, InsertGT3_Sorted); INJECT(0x0040A5D0, InsertClippedPoly_Textured); INJECT(0x0040A780, InsertGT4_Sorted); INJECT(0x0040AC60, InsertObjectGT4_Sorted); INJECT(0x0040ACF0, InsertObjectGT3_Sorted); INJECT(0x0040AD90, InsertObjectG4_Sorted); INJECT(0x0040B1D0, InsertPoly_Gouraud); INJECT(0x0040B350, InsertObjectG3_Sorted); INJECT(0x0040B6A0, InsertSprite_Sorted); INJECT(0x0040B9F0, InsertFlatRect_Sorted); INJECT(0x0040BB70, InsertLine_Sorted); INJECT(0x0040BCA0, InsertTrans8_Sorted); INJECT(0x0040BE40, InsertTransQuad_Sorted); INJECT(0x0040BF80, InsertSprite); } ================================================ FILE: 3dsystem/3dinsert.h ================================================ /* * Copyright (c) 2017-2020 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #ifndef _3DINSERT_H_INCLUDED #define _3DINSERT_H_INCLUDED #include "global/types.h" /* * Function list */ #ifdef FEATURE_VIDEOFX_IMPROVED bool InsertObjectEM(__int16 *ptrObj, int vtxCount, D3DCOLOR tint, PHD_UV *em_uv); #endif // FEATURE_VIDEOFX_IMPROVED // NOTE: this function is not presented in the original game void InsertGourQuad(int x0, int y0, int x1, int y1, int z, D3DCOLOR color0, D3DCOLOR color1, D3DCOLOR color2, D3DCOLOR color3); BOOL __cdecl visible_zclip(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2); // 0x00405840 int __cdecl ZedClipper(int vtxCount, POINT_INFO *pts, VERTEX_INFO *vtx); // 0x004058B0 int __cdecl XYGUVClipper(int vtxCount, VERTEX_INFO *vtx); // 0x004059F0 __int16 *__cdecl InsertObjectGT4(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00405F10 __int16 *__cdecl InsertObjectGT3(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00406970 int __cdecl XYGClipper(int vtxCount, VERTEX_INFO *vtx); // 0x004071F0 __int16 *__cdecl InsertObjectG4(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00407620 __int16 *__cdecl InsertObjectG3(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00407A00 int __cdecl XYClipper(int vtxCount, VERTEX_INFO *vtx); // 0x00407D20 void __cdecl InsertTrans8(PHD_VBUF *vbuf, __int16 shade); // 0x00407FF0 void __cdecl InsertTransQuad(int x, int y, int width, int height, int z); // 0x004084A0 void __cdecl InsertFlatRect(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x00408580 void __cdecl InsertLine(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x00408650 void __cdecl InsertGT3_ZBuffered(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_TEXTURE *texture, PHD_UV *uv0, PHD_UV *uv1, PHD_UV *uv2); // 0x00408710 void __cdecl DrawClippedPoly_Textured(int vtxCount); // 0x00408D60 void __cdecl InsertGT4_ZBuffered(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_VBUF *vtx3, PHD_TEXTURE *texture); // 0x00408EA0 __int16 *__cdecl InsertObjectGT4_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x004092E0 __int16 *__cdecl InsertObjectGT3_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00409380 __int16 *__cdecl InsertObjectG4_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x00409430 void __cdecl DrawPoly_Gouraud(int vtxCount, int red, int green, int blue); // 0x004097D0 __int16 *__cdecl InsertObjectG3_ZBuffered(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x004098D0 void __cdecl InsertFlatRect_ZBuffered(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x00409BB0 void __cdecl InsertLine_ZBuffered(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x00409D80 void __cdecl InsertGT3_Sorted(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_TEXTURE *texture, PHD_UV *uv0, PHD_UV *uv1, PHD_UV *uv2, SORTTYPE sortType); // 0x00409EC0 void __cdecl InsertClippedPoly_Textured(int vtxCount, float z, __int16 polyType, __int16 texPage); // 0x0040A5D0 void __cdecl InsertGT4_Sorted(PHD_VBUF *vtx0, PHD_VBUF *vtx1, PHD_VBUF *vtx2, PHD_VBUF *vtx3, PHD_TEXTURE *texture, SORTTYPE sortType); // 0x0040A780 __int16 *__cdecl InsertObjectGT4_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x0040AC60 __int16 *__cdecl InsertObjectGT3_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x0040ACF0 __int16 *__cdecl InsertObjectG4_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x0040AD90 void __cdecl InsertPoly_Gouraud(int vtxCount, float z, int red, int green, int blue, __int16 polyType); // 0x0040B1D0 __int16 *__cdecl InsertObjectG3_Sorted(__int16 *ptrObj, int number, SORTTYPE sortType); // 0x0040B350 #ifdef FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade, DWORD flags); // 0x0040B6A0 #else // FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade); // 0x0040B6A0 #endif // FEATURE_VIDEOFX_IMPROVED void __cdecl InsertFlatRect_Sorted(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x0040B9F0 void __cdecl InsertLine_Sorted(int x0, int y0, int x1, int y1, int z, BYTE colorIdx); // 0x0040BB70 void __cdecl InsertTrans8_Sorted(PHD_VBUF *vbuf, __int16 shade); // 0x0040BCA0 void __cdecl InsertTransQuad_Sorted(int x, int y, int width, int height, int z); // 0x0040BE40 #ifdef FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade, DWORD flags); // 0x0040BF80 #else // FEATURE_VIDEOFX_IMPROVED void __cdecl InsertSprite(int z, int x0, int y0, int x1, int y1, int spriteIdx, __int16 shade); // 0x0040BF80 #endif // FEATURE_VIDEOFX_IMPROVED #endif // _3DINSERT_H_INCLUDED ================================================ FILE: 3dsystem/phd_math.cpp ================================================ /* * Copyright (c) 2017-2018 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #include "global/precompiled.h" #include "3dsystem/phd_math.h" #include "global/vars.h" // Arctan base table static int AtanBaseTable[8] = { 0x0000, -0x4000, -0xFFFF, 0xC000, -0x8000, 0x4000, 0x8000, -0xC000, }; // Arctan angle table static __int16 AtanAngleTable[0x802] = { 0x0000, 0x0005, 0x000A, 0x000F, 0x0014, 0x0019, 0x001F, 0x0024, 0x0029, 0x002E, 0x0033, 0x0038, 0x003D, 0x0042, 0x0047, 0x004C, 0x0051, 0x0057, 0x005C, 0x0061, 0x0066, 0x006B, 0x0070, 0x0075, 0x007A, 0x007F, 0x0084, 0x008A, 0x008F, 0x0094, 0x0099, 0x009E, 0x00A3, 0x00A8, 0x00AD, 0x00B2, 0x00B7, 0x00BC, 0x00C2, 0x00C7, 0x00CC, 0x00D1, 0x00D6, 0x00DB, 0x00E0, 0x00E5, 0x00EA, 0x00EF, 0x00F4, 0x00FA, 0x00FF, 0x0104, 0x0109, 0x010E, 0x0113, 0x0118, 0x011D, 0x0122, 0x0127, 0x012C, 0x0131, 0x0137, 0x013C, 0x0141, 0x0146, 0x014B, 0x0150, 0x0155, 0x015A, 0x015F, 0x0164, 0x0169, 0x016F, 0x0174, 0x0179, 0x017E, 0x0183, 0x0188, 0x018D, 0x0192, 0x0197, 0x019C, 0x01A1, 0x01A6, 0x01AC, 0x01B1, 0x01B6, 0x01BB, 0x01C0, 0x01C5, 0x01CA, 0x01CF, 0x01D4, 0x01D9, 0x01DE, 0x01E3, 0x01E9, 0x01EE, 0x01F3, 0x01F8, 0x01FD, 0x0202, 0x0207, 0x020C, 0x0211, 0x0216, 0x021B, 0x0220, 0x0226, 0x022B, 0x0230, 0x0235, 0x023A, 0x023F, 0x0244, 0x0249, 0x024E, 0x0253, 0x0258, 0x025D, 0x0262, 0x0268, 0x026D, 0x0272, 0x0277, 0x027C, 0x0281, 0x0286, 0x028B, 0x0290, 0x0295, 0x029A, 0x029F, 0x02A4, 0x02A9, 0x02AF, 0x02B4, 0x02B9, 0x02BE, 0x02C3, 0x02C8, 0x02CD, 0x02D2, 0x02D7, 0x02DC, 0x02E1, 0x02E6, 0x02EB, 0x02F0, 0x02F6, 0x02FB, 0x0300, 0x0305, 0x030A, 0x030F, 0x0314, 0x0319, 0x031E, 0x0323, 0x0328, 0x032D, 0x0332, 0x0337, 0x033C, 0x0341, 0x0347, 0x034C, 0x0351, 0x0356, 0x035B, 0x0360, 0x0365, 0x036A, 0x036F, 0x0374, 0x0379, 0x037E, 0x0383, 0x0388, 0x038D, 0x0392, 0x0397, 0x039C, 0x03A2, 0x03A7, 0x03AC, 0x03B1, 0x03B6, 0x03BB, 0x03C0, 0x03C5, 0x03CA, 0x03CF, 0x03D4, 0x03D9, 0x03DE, 0x03E3, 0x03E8, 0x03ED, 0x03F2, 0x03F7, 0x03FC, 0x0401, 0x0407, 0x040C, 0x0411, 0x0416, 0x041B, 0x0420, 0x0425, 0x042A, 0x042F, 0x0434, 0x0439, 0x043E, 0x0443, 0x0448, 0x044D, 0x0452, 0x0457, 0x045C, 0x0461, 0x0466, 0x046B, 0x0470, 0x0475, 0x047A, 0x047F, 0x0484, 0x0489, 0x048E, 0x0494, 0x0499, 0x049E, 0x04A3, 0x04A8, 0x04AD, 0x04B2, 0x04B7, 0x04BC, 0x04C1, 0x04C6, 0x04CB, 0x04D0, 0x04D5, 0x04DA, 0x04DF, 0x04E4, 0x04E9, 0x04EE, 0x04F3, 0x04F8, 0x04FD, 0x0502, 0x0507, 0x050C, 0x0511, 0x0516, 0x051B, 0x0520, 0x0525, 0x052A, 0x052F, 0x0534, 0x0539, 0x053E, 0x0543, 0x0548, 0x054D, 0x0552, 0x0557, 0x055C, 0x0561, 0x0566, 0x056B, 0x0570, 0x0575, 0x057A, 0x057F, 0x0584, 0x0589, 0x058E, 0x0593, 0x0598, 0x059D, 0x05A2, 0x05A7, 0x05AC, 0x05B1, 0x05B6, 0x05BB, 0x05C0, 0x05C5, 0x05CA, 0x05CF, 0x05D4, 0x05D9, 0x05DE, 0x05E3, 0x05E8, 0x05ED, 0x05F2, 0x05F7, 0x05FC, 0x0601, 0x0606, 0x060B, 0x0610, 0x0615, 0x061A, 0x061F, 0x0624, 0x0629, 0x062E, 0x0633, 0x0638, 0x063D, 0x0642, 0x0647, 0x064C, 0x0651, 0x0656, 0x065B, 0x0660, 0x0665, 0x066A, 0x066E, 0x0673, 0x0678, 0x067D, 0x0682, 0x0687, 0x068C, 0x0691, 0x0696, 0x069B, 0x06A0, 0x06A5, 0x06AA, 0x06AF, 0x06B4, 0x06B9, 0x06BE, 0x06C3, 0x06C8, 0x06CD, 0x06D2, 0x06D7, 0x06DC, 0x06E1, 0x06E5, 0x06EA, 0x06EF, 0x06F4, 0x06F9, 0x06FE, 0x0703, 0x0708, 0x070D, 0x0712, 0x0717, 0x071C, 0x0721, 0x0726, 0x072B, 0x0730, 0x0735, 0x0739, 0x073E, 0x0743, 0x0748, 0x074D, 0x0752, 0x0757, 0x075C, 0x0761, 0x0766, 0x076B, 0x0770, 0x0775, 0x077A, 0x077E, 0x0783, 0x0788, 0x078D, 0x0792, 0x0797, 0x079C, 0x07A1, 0x07A6, 0x07AB, 0x07B0, 0x07B5, 0x07B9, 0x07BE, 0x07C3, 0x07C8, 0x07CD, 0x07D2, 0x07D7, 0x07DC, 0x07E1, 0x07E6, 0x07EB, 0x07EF, 0x07F4, 0x07F9, 0x07FE, 0x0803, 0x0808, 0x080D, 0x0812, 0x0817, 0x081C, 0x0820, 0x0825, 0x082A, 0x082F, 0x0834, 0x0839, 0x083E, 0x0843, 0x0848, 0x084C, 0x0851, 0x0856, 0x085B, 0x0860, 0x0865, 0x086A, 0x086F, 0x0873, 0x0878, 0x087D, 0x0882, 0x0887, 0x088C, 0x0891, 0x0896, 0x089A, 0x089F, 0x08A4, 0x08A9, 0x08AE, 0x08B3, 0x08B8, 0x08BD, 0x08C1, 0x08C6, 0x08CB, 0x08D0, 0x08D5, 0x08DA, 0x08DF, 0x08E3, 0x08E8, 0x08ED, 0x08F2, 0x08F7, 0x08FC, 0x0901, 0x0905, 0x090A, 0x090F, 0x0914, 0x0919, 0x091E, 0x0922, 0x0927, 0x092C, 0x0931, 0x0936, 0x093B, 0x093F, 0x0944, 0x0949, 0x094E, 0x0953, 0x0958, 0x095C, 0x0961, 0x0966, 0x096B, 0x0970, 0x0975, 0x0979, 0x097E, 0x0983, 0x0988, 0x098D, 0x0992, 0x0996, 0x099B, 0x09A0, 0x09A5, 0x09AA, 0x09AE, 0x09B3, 0x09B8, 0x09BD, 0x09C2, 0x09C6, 0x09CB, 0x09D0, 0x09D5, 0x09DA, 0x09DE, 0x09E3, 0x09E8, 0x09ED, 0x09F2, 0x09F6, 0x09FB, 0x0A00, 0x0A05, 0x0A0A, 0x0A0E, 0x0A13, 0x0A18, 0x0A1D, 0x0A22, 0x0A26, 0x0A2B, 0x0A30, 0x0A35, 0x0A39, 0x0A3E, 0x0A43, 0x0A48, 0x0A4D, 0x0A51, 0x0A56, 0x0A5B, 0x0A60, 0x0A64, 0x0A69, 0x0A6E, 0x0A73, 0x0A77, 0x0A7C, 0x0A81, 0x0A86, 0x0A8B, 0x0A8F, 0x0A94, 0x0A99, 0x0A9E, 0x0AA2, 0x0AA7, 0x0AAC, 0x0AB1, 0x0AB5, 0x0ABA, 0x0ABF, 0x0AC4, 0x0AC8, 0x0ACD, 0x0AD2, 0x0AD7, 0x0ADB, 0x0AE0, 0x0AE5, 0x0AE9, 0x0AEE, 0x0AF3, 0x0AF8, 0x0AFC, 0x0B01, 0x0B06, 0x0B0B, 0x0B0F, 0x0B14, 0x0B19, 0x0B1E, 0x0B22, 0x0B27, 0x0B2C, 0x0B30, 0x0B35, 0x0B3A, 0x0B3F, 0x0B43, 0x0B48, 0x0B4D, 0x0B51, 0x0B56, 0x0B5B, 0x0B60, 0x0B64, 0x0B69, 0x0B6E, 0x0B72, 0x0B77, 0x0B7C, 0x0B80, 0x0B85, 0x0B8A, 0x0B8F, 0x0B93, 0x0B98, 0x0B9D, 0x0BA1, 0x0BA6, 0x0BAB, 0x0BAF, 0x0BB4, 0x0BB9, 0x0BBD, 0x0BC2, 0x0BC7, 0x0BCB, 0x0BD0, 0x0BD5, 0x0BD9, 0x0BDE, 0x0BE3, 0x0BE7, 0x0BEC, 0x0BF1, 0x0BF5, 0x0BFA, 0x0BFF, 0x0C03, 0x0C08, 0x0C0D, 0x0C11, 0x0C16, 0x0C1B, 0x0C1F, 0x0C24, 0x0C29, 0x0C2D, 0x0C32, 0x0C37, 0x0C3B, 0x0C40, 0x0C45, 0x0C49, 0x0C4E, 0x0C53, 0x0C57, 0x0C5C, 0x0C60, 0x0C65, 0x0C6A, 0x0C6E, 0x0C73, 0x0C78, 0x0C7C, 0x0C81, 0x0C86, 0x0C8A, 0x0C8F, 0x0C93, 0x0C98, 0x0C9D, 0x0CA1, 0x0CA6, 0x0CAB, 0x0CAF, 0x0CB4, 0x0CB8, 0x0CBD, 0x0CC2, 0x0CC6, 0x0CCB, 0x0CCF, 0x0CD4, 0x0CD9, 0x0CDD, 0x0CE2, 0x0CE6, 0x0CEB, 0x0CF0, 0x0CF4, 0x0CF9, 0x0CFD, 0x0D02, 0x0D07, 0x0D0B, 0x0D10, 0x0D14, 0x0D19, 0x0D1E, 0x0D22, 0x0D27, 0x0D2B, 0x0D30, 0x0D34, 0x0D39, 0x0D3E, 0x0D42, 0x0D47, 0x0D4B, 0x0D50, 0x0D54, 0x0D59, 0x0D5E, 0x0D62, 0x0D67, 0x0D6B, 0x0D70, 0x0D74, 0x0D79, 0x0D7D, 0x0D82, 0x0D87, 0x0D8B, 0x0D90, 0x0D94, 0x0D99, 0x0D9D, 0x0DA2, 0x0DA6, 0x0DAB, 0x0DAF, 0x0DB4, 0x0DB9, 0x0DBD, 0x0DC2, 0x0DC6, 0x0DCB, 0x0DCF, 0x0DD4, 0x0DD8, 0x0DDD, 0x0DE1, 0x0DE6, 0x0DEA, 0x0DEF, 0x0DF3, 0x0DF8, 0x0DFC, 0x0E01, 0x0E05, 0x0E0A, 0x0E0F, 0x0E13, 0x0E18, 0x0E1C, 0x0E21, 0x0E25, 0x0E2A, 0x0E2E, 0x0E33, 0x0E37, 0x0E3C, 0x0E40, 0x0E45, 0x0E49, 0x0E4E, 0x0E52, 0x0E56, 0x0E5B, 0x0E5F, 0x0E64, 0x0E68, 0x0E6D, 0x0E71, 0x0E76, 0x0E7A, 0x0E7F, 0x0E83, 0x0E88, 0x0E8C, 0x0E91, 0x0E95, 0x0E9A, 0x0E9E, 0x0EA3, 0x0EA7, 0x0EAC, 0x0EB0, 0x0EB4, 0x0EB9, 0x0EBD, 0x0EC2, 0x0EC6, 0x0ECB, 0x0ECF, 0x0ED4, 0x0ED8, 0x0EDC, 0x0EE1, 0x0EE5, 0x0EEA, 0x0EEE, 0x0EF3, 0x0EF7, 0x0EFC, 0x0F00, 0x0F04, 0x0F09, 0x0F0D, 0x0F12, 0x0F16, 0x0F1B, 0x0F1F, 0x0F23, 0x0F28, 0x0F2C, 0x0F31, 0x0F35, 0x0F3A, 0x0F3E, 0x0F42, 0x0F47, 0x0F4B, 0x0F50, 0x0F54, 0x0F58, 0x0F5D, 0x0F61, 0x0F66, 0x0F6A, 0x0F6E, 0x0F73, 0x0F77, 0x0F7C, 0x0F80, 0x0F84, 0x0F89, 0x0F8D, 0x0F91, 0x0F96, 0x0F9A, 0x0F9F, 0x0FA3, 0x0FA7, 0x0FAC, 0x0FB0, 0x0FB5, 0x0FB9, 0x0FBD, 0x0FC2, 0x0FC6, 0x0FCA, 0x0FCF, 0x0FD3, 0x0FD7, 0x0FDC, 0x0FE0, 0x0FE5, 0x0FE9, 0x0FED, 0x0FF2, 0x0FF6, 0x0FFA, 0x0FFF, 0x1003, 0x1007, 0x100C, 0x1010, 0x1014, 0x1019, 0x101D, 0x1021, 0x1026, 0x102A, 0x102E, 0x1033, 0x1037, 0x103B, 0x1040, 0x1044, 0x1048, 0x104D, 0x1051, 0x1055, 0x105A, 0x105E, 0x1062, 0x1067, 0x106B, 0x106F, 0x1073, 0x1078, 0x107C, 0x1080, 0x1085, 0x1089, 0x108D, 0x1092, 0x1096, 0x109A, 0x109E, 0x10A3, 0x10A7, 0x10AB, 0x10B0, 0x10B4, 0x10B8, 0x10BC, 0x10C1, 0x10C5, 0x10C9, 0x10CE, 0x10D2, 0x10D6, 0x10DA, 0x10DF, 0x10E3, 0x10E7, 0x10EB, 0x10F0, 0x10F4, 0x10F8, 0x10FD, 0x1101, 0x1105, 0x1109, 0x110E, 0x1112, 0x1116, 0x111A, 0x111F, 0x1123, 0x1127, 0x112B, 0x1130, 0x1134, 0x1138, 0x113C, 0x1140, 0x1145, 0x1149, 0x114D, 0x1151, 0x1156, 0x115A, 0x115E, 0x1162, 0x1166, 0x116B, 0x116F, 0x1173, 0x1177, 0x117C, 0x1180, 0x1184, 0x1188, 0x118C, 0x1191, 0x1195, 0x1199, 0x119D, 0x11A1, 0x11A6, 0x11AA, 0x11AE, 0x11B2, 0x11B6, 0x11BB, 0x11BF, 0x11C3, 0x11C7, 0x11CB, 0x11CF, 0x11D4, 0x11D8, 0x11DC, 0x11E0, 0x11E4, 0x11E9, 0x11ED, 0x11F1, 0x11F5, 0x11F9, 0x11FD, 0x1202, 0x1206, 0x120A, 0x120E, 0x1212, 0x1216, 0x121A, 0x121F, 0x1223, 0x1227, 0x122B, 0x122F, 0x1233, 0x1237, 0x123C, 0x1240, 0x1244, 0x1248, 0x124C, 0x1250, 0x1254, 0x1259, 0x125D, 0x1261, 0x1265, 0x1269, 0x126D, 0x1271, 0x1275, 0x127A, 0x127E, 0x1282, 0x1286, 0x128A, 0x128E, 0x1292, 0x1296, 0x129A, 0x129F, 0x12A3, 0x12A7, 0x12AB, 0x12AF, 0x12B3, 0x12B7, 0x12BB, 0x12BF, 0x12C3, 0x12C7, 0x12CC, 0x12D0, 0x12D4, 0x12D8, 0x12DC, 0x12E0, 0x12E4, 0x12E8, 0x12EC, 0x12F0, 0x12F4, 0x12F8, 0x12FC, 0x1301, 0x1305, 0x1309, 0x130D, 0x1311, 0x1315, 0x1319, 0x131D, 0x1321, 0x1325, 0x1329, 0x132D, 0x1331, 0x1335, 0x1339, 0x133D, 0x1341, 0x1345, 0x1349, 0x134D, 0x1351, 0x1355, 0x135A, 0x135E, 0x1362, 0x1366, 0x136A, 0x136E, 0x1372, 0x1376, 0x137A, 0x137E, 0x1382, 0x1386, 0x138A, 0x138E, 0x1392, 0x1396, 0x139A, 0x139E, 0x13A2, 0x13A6, 0x13AA, 0x13AE, 0x13B2, 0x13B6, 0x13BA, 0x13BE, 0x13C2, 0x13C6, 0x13CA, 0x13CE, 0x13D2, 0x13D6, 0x13DA, 0x13DE, 0x13E2, 0x13E6, 0x13E9, 0x13ED, 0x13F1, 0x13F5, 0x13F9, 0x13FD, 0x1401, 0x1405, 0x1409, 0x140D, 0x1411, 0x1415, 0x1419, 0x141D, 0x1421, 0x1425, 0x1429, 0x142D, 0x1431, 0x1435, 0x1439, 0x143D, 0x1440, 0x1444, 0x1448, 0x144C, 0x1450, 0x1454, 0x1458, 0x145C, 0x1460, 0x1464, 0x1468, 0x146C, 0x1470, 0x1473, 0x1477, 0x147B, 0x147F, 0x1483, 0x1487, 0x148B, 0x148F, 0x1493, 0x1497, 0x149B, 0x149E, 0x14A2, 0x14A6, 0x14AA, 0x14AE, 0x14B2, 0x14B6, 0x14BA, 0x14BE, 0x14C1, 0x14C5, 0x14C9, 0x14CD, 0x14D1, 0x14D5, 0x14D9, 0x14DD, 0x14E0, 0x14E4, 0x14E8, 0x14EC, 0x14F0, 0x14F4, 0x14F8, 0x14FB, 0x14FF, 0x1503, 0x1507, 0x150B, 0x150F, 0x1513, 0x1516, 0x151A, 0x151E, 0x1522, 0x1526, 0x152A, 0x152D, 0x1531, 0x1535, 0x1539, 0x153D, 0x1541, 0x1544, 0x1548, 0x154C, 0x1550, 0x1554, 0x1558, 0x155B, 0x155F, 0x1563, 0x1567, 0x156B, 0x156E, 0x1572, 0x1576, 0x157A, 0x157E, 0x1581, 0x1585, 0x1589, 0x158D, 0x1591, 0x1594, 0x1598, 0x159C, 0x15A0, 0x15A4, 0x15A7, 0x15AB, 0x15AF, 0x15B3, 0x15B7, 0x15BA, 0x15BE, 0x15C2, 0x15C6, 0x15C9, 0x15CD, 0x15D1, 0x15D5, 0x15D8, 0x15DC, 0x15E0, 0x15E4, 0x15E8, 0x15EB, 0x15EF, 0x15F3, 0x15F7, 0x15FA, 0x15FE, 0x1602, 0x1606, 0x1609, 0x160D, 0x1611, 0x1614, 0x1618, 0x161C, 0x1620, 0x1623, 0x1627, 0x162B, 0x162F, 0x1632, 0x1636, 0x163A, 0x163E, 0x1641, 0x1645, 0x1649, 0x164C, 0x1650, 0x1654, 0x1658, 0x165B, 0x165F, 0x1663, 0x1666, 0x166A, 0x166E, 0x1671, 0x1675, 0x1679, 0x167D, 0x1680, 0x1684, 0x1688, 0x168B, 0x168F, 0x1693, 0x1696, 0x169A, 0x169E, 0x16A1, 0x16A5, 0x16A9, 0x16AC, 0x16B0, 0x16B4, 0x16B7, 0x16BB, 0x16BF, 0x16C2, 0x16C6, 0x16CA, 0x16CD, 0x16D1, 0x16D5, 0x16D8, 0x16DC, 0x16E0, 0x16E3, 0x16E7, 0x16EB, 0x16EE, 0x16F2, 0x16F6, 0x16F9, 0x16FD, 0x1700, 0x1704, 0x1708, 0x170B, 0x170F, 0x1713, 0x1716, 0x171A, 0x171D, 0x1721, 0x1725, 0x1728, 0x172C, 0x1730, 0x1733, 0x1737, 0x173A, 0x173E, 0x1742, 0x1745, 0x1749, 0x174C, 0x1750, 0x1754, 0x1757, 0x175B, 0x175E, 0x1762, 0x1766, 0x1769, 0x176D, 0x1770, 0x1774, 0x1778, 0x177B, 0x177F, 0x1782, 0x1786, 0x1789, 0x178D, 0x1791, 0x1794, 0x1798, 0x179B, 0x179F, 0x17A2, 0x17A6, 0x17AA, 0x17AD, 0x17B1, 0x17B4, 0x17B8, 0x17BB, 0x17BF, 0x17C2, 0x17C6, 0x17C9, 0x17CD, 0x17D1, 0x17D4, 0x17D8, 0x17DB, 0x17DF, 0x17E2, 0x17E6, 0x17E9, 0x17ED, 0x17F0, 0x17F4, 0x17F7, 0x17FB, 0x17FE, 0x1802, 0x1806, 0x1809, 0x180D, 0x1810, 0x1814, 0x1817, 0x181B, 0x181E, 0x1822, 0x1825, 0x1829, 0x182C, 0x1830, 0x1833, 0x1837, 0x183A, 0x183E, 0x1841, 0x1845, 0x1848, 0x184C, 0x184F, 0x1853, 0x1856, 0x185A, 0x185D, 0x1860, 0x1864, 0x1867, 0x186B, 0x186E, 0x1872, 0x1875, 0x1879, 0x187C, 0x1880, 0x1883, 0x1887, 0x188A, 0x188E, 0x1891, 0x1894, 0x1898, 0x189B, 0x189F, 0x18A2, 0x18A6, 0x18A9, 0x18AD, 0x18B0, 0x18B3, 0x18B7, 0x18BA, 0x18BE, 0x18C1, 0x18C5, 0x18C8, 0x18CC, 0x18CF, 0x18D2, 0x18D6, 0x18D9, 0x18DD, 0x18E0, 0x18E3, 0x18E7, 0x18EA, 0x18EE, 0x18F1, 0x18F5, 0x18F8, 0x18FB, 0x18FF, 0x1902, 0x1906, 0x1909, 0x190C, 0x1910, 0x1913, 0x1917, 0x191A, 0x191D, 0x1921, 0x1924, 0x1928, 0x192B, 0x192E, 0x1932, 0x1935, 0x1938, 0x193C, 0x193F, 0x1943, 0x1946, 0x1949, 0x194D, 0x1950, 0x1953, 0x1957, 0x195A, 0x195D, 0x1961, 0x1964, 0x1968, 0x196B, 0x196E, 0x1972, 0x1975, 0x1978, 0x197C, 0x197F, 0x1982, 0x1986, 0x1989, 0x198C, 0x1990, 0x1993, 0x1996, 0x199A, 0x199D, 0x19A0, 0x19A4, 0x19A7, 0x19AA, 0x19AE, 0x19B1, 0x19B4, 0x19B8, 0x19BB, 0x19BE, 0x19C2, 0x19C5, 0x19C8, 0x19CC, 0x19CF, 0x19D2, 0x19D5, 0x19D9, 0x19DC, 0x19DF, 0x19E3, 0x19E6, 0x19E9, 0x19ED, 0x19F0, 0x19F3, 0x19F6, 0x19FA, 0x19FD, 0x1A00, 0x1A04, 0x1A07, 0x1A0A, 0x1A0D, 0x1A11, 0x1A14, 0x1A17, 0x1A1B, 0x1A1E, 0x1A21, 0x1A24, 0x1A28, 0x1A2B, 0x1A2E, 0x1A31, 0x1A35, 0x1A38, 0x1A3B, 0x1A3E, 0x1A42, 0x1A45, 0x1A48, 0x1A4B, 0x1A4F, 0x1A52, 0x1A55, 0x1A58, 0x1A5C, 0x1A5F, 0x1A62, 0x1A65, 0x1A69, 0x1A6C, 0x1A6F, 0x1A72, 0x1A76, 0x1A79, 0x1A7C, 0x1A7F, 0x1A83, 0x1A86, 0x1A89, 0x1A8C, 0x1A8F, 0x1A93, 0x1A96, 0x1A99, 0x1A9C, 0x1A9F, 0x1AA3, 0x1AA6, 0x1AA9, 0x1AAC, 0x1AB0, 0x1AB3, 0x1AB6, 0x1AB9, 0x1ABC, 0x1AC0, 0x1AC3, 0x1AC6, 0x1AC9, 0x1ACC, 0x1ACF, 0x1AD3, 0x1AD6, 0x1AD9, 0x1ADC, 0x1ADF, 0x1AE3, 0x1AE6, 0x1AE9, 0x1AEC, 0x1AEF, 0x1AF2, 0x1AF6, 0x1AF9, 0x1AFC, 0x1AFF, 0x1B02, 0x1B05, 0x1B09, 0x1B0C, 0x1B0F, 0x1B12, 0x1B15, 0x1B18, 0x1B1C, 0x1B1F, 0x1B22, 0x1B25, 0x1B28, 0x1B2B, 0x1B2E, 0x1B32, 0x1B35, 0x1B38, 0x1B3B, 0x1B3E, 0x1B41, 0x1B44, 0x1B48, 0x1B4B, 0x1B4E, 0x1B51, 0x1B54, 0x1B57, 0x1B5A, 0x1B5D, 0x1B61, 0x1B64, 0x1B67, 0x1B6A, 0x1B6D, 0x1B70, 0x1B73, 0x1B76, 0x1B79, 0x1B7D, 0x1B80, 0x1B83, 0x1B86, 0x1B89, 0x1B8C, 0x1B8F, 0x1B92, 0x1B95, 0x1B98, 0x1B9C, 0x1B9F, 0x1BA2, 0x1BA5, 0x1BA8, 0x1BAB, 0x1BAE, 0x1BB1, 0x1BB4, 0x1BB7, 0x1BBA, 0x1BBD, 0x1BC1, 0x1BC4, 0x1BC7, 0x1BCA, 0x1BCD, 0x1BD0, 0x1BD3, 0x1BD6, 0x1BD9, 0x1BDC, 0x1BDF, 0x1BE2, 0x1BE5, 0x1BE8, 0x1BEB, 0x1BEE, 0x1BF2, 0x1BF5, 0x1BF8, 0x1BFB, 0x1BFE, 0x1C01, 0x1C04, 0x1C07, 0x1C0A, 0x1C0D, 0x1C10, 0x1C13, 0x1C16, 0x1C19, 0x1C1C, 0x1C1F, 0x1C22, 0x1C25, 0x1C28, 0x1C2B, 0x1C2E, 0x1C31, 0x1C34, 0x1C37, 0x1C3A, 0x1C3D, 0x1C40, 0x1C43, 0x1C46, 0x1C49, 0x1C4C, 0x1C4F, 0x1C52, 0x1C55, 0x1C58, 0x1C5B, 0x1C5E, 0x1C61, 0x1C64, 0x1C67, 0x1C6A, 0x1C6D, 0x1C70, 0x1C73, 0x1C76, 0x1C79, 0x1C7C, 0x1C7F, 0x1C82, 0x1C85, 0x1C88, 0x1C8B, 0x1C8E, 0x1C91, 0x1C94, 0x1C97, 0x1C9A, 0x1C9D, 0x1CA0, 0x1CA3, 0x1CA6, 0x1CA9, 0x1CAC, 0x1CAF, 0x1CB2, 0x1CB5, 0x1CB8, 0x1CBB, 0x1CBE, 0x1CC1, 0x1CC3, 0x1CC6, 0x1CC9, 0x1CCC, 0x1CCF, 0x1CD2, 0x1CD5, 0x1CD8, 0x1CDB, 0x1CDE, 0x1CE1, 0x1CE4, 0x1CE7, 0x1CEA, 0x1CED, 0x1CF0, 0x1CF3, 0x1CF5, 0x1CF8, 0x1CFB, 0x1CFE, 0x1D01, 0x1D04, 0x1D07, 0x1D0A, 0x1D0D, 0x1D10, 0x1D13, 0x1D16, 0x1D18, 0x1D1B, 0x1D1E, 0x1D21, 0x1D24, 0x1D27, 0x1D2A, 0x1D2D, 0x1D30, 0x1D33, 0x1D35, 0x1D38, 0x1D3B, 0x1D3E, 0x1D41, 0x1D44, 0x1D47, 0x1D4A, 0x1D4D, 0x1D4F, 0x1D52, 0x1D55, 0x1D58, 0x1D5B, 0x1D5E, 0x1D61, 0x1D64, 0x1D66, 0x1D69, 0x1D6C, 0x1D6F, 0x1D72, 0x1D75, 0x1D78, 0x1D7B, 0x1D7D, 0x1D80, 0x1D83, 0x1D86, 0x1D89, 0x1D8C, 0x1D8E, 0x1D91, 0x1D94, 0x1D97, 0x1D9A, 0x1D9D, 0x1DA0, 0x1DA2, 0x1DA5, 0x1DA8, 0x1DAB, 0x1DAE, 0x1DB1, 0x1DB3, 0x1DB6, 0x1DB9, 0x1DBC, 0x1DBF, 0x1DC2, 0x1DC4, 0x1DC7, 0x1DCA, 0x1DCD, 0x1DD0, 0x1DD3, 0x1DD5, 0x1DD8, 0x1DDB, 0x1DDE, 0x1DE1, 0x1DE3, 0x1DE6, 0x1DE9, 0x1DEC, 0x1DEF, 0x1DF1, 0x1DF4, 0x1DF7, 0x1DFA, 0x1DFD, 0x1DFF, 0x1E02, 0x1E05, 0x1E08, 0x1E0B, 0x1E0D, 0x1E10, 0x1E13, 0x1E16, 0x1E19, 0x1E1B, 0x1E1E, 0x1E21, 0x1E24, 0x1E26, 0x1E29, 0x1E2C, 0x1E2F, 0x1E32, 0x1E34, 0x1E37, 0x1E3A, 0x1E3D, 0x1E3F, 0x1E42, 0x1E45, 0x1E48, 0x1E4A, 0x1E4D, 0x1E50, 0x1E53, 0x1E55, 0x1E58, 0x1E5B, 0x1E5E, 0x1E60, 0x1E63, 0x1E66, 0x1E69, 0x1E6B, 0x1E6E, 0x1E71, 0x1E74, 0x1E76, 0x1E79, 0x1E7C, 0x1E7F, 0x1E81, 0x1E84, 0x1E87, 0x1E8A, 0x1E8C, 0x1E8F, 0x1E92, 0x1E94, 0x1E97, 0x1E9A, 0x1E9D, 0x1E9F, 0x1EA2, 0x1EA5, 0x1EA8, 0x1EAA, 0x1EAD, 0x1EB0, 0x1EB2, 0x1EB5, 0x1EB8, 0x1EBA, 0x1EBD, 0x1EC0, 0x1EC3, 0x1EC5, 0x1EC8, 0x1ECB, 0x1ECD, 0x1ED0, 0x1ED3, 0x1ED5, 0x1ED8, 0x1EDB, 0x1EDE, 0x1EE0, 0x1EE3, 0x1EE6, 0x1EE8, 0x1EEB, 0x1EEE, 0x1EF0, 0x1EF3, 0x1EF6, 0x1EF8, 0x1EFB, 0x1EFE, 0x1F00, 0x1F03, 0x1F06, 0x1F08, 0x1F0B, 0x1F0E, 0x1F10, 0x1F13, 0x1F16, 0x1F18, 0x1F1B, 0x1F1E, 0x1F20, 0x1F23, 0x1F26, 0x1F28, 0x1F2B, 0x1F2E, 0x1F30, 0x1F33, 0x1F36, 0x1F38, 0x1F3B, 0x1F3D, 0x1F40, 0x1F43, 0x1F45, 0x1F48, 0x1F4B, 0x1F4D, 0x1F50, 0x1F53, 0x1F55, 0x1F58, 0x1F5A, 0x1F5D, 0x1F60, 0x1F62, 0x1F65, 0x1F68, 0x1F6A, 0x1F6D, 0x1F6F, 0x1F72, 0x1F75, 0x1F77, 0x1F7A, 0x1F7C, 0x1F7F, 0x1F82, 0x1F84, 0x1F87, 0x1F8A, 0x1F8C, 0x1F8F, 0x1F91, 0x1F94, 0x1F97, 0x1F99, 0x1F9C, 0x1F9E, 0x1FA1, 0x1FA4, 0x1FA6, 0x1FA9, 0x1FAB, 0x1FAE, 0x1FB0, 0x1FB3, 0x1FB6, 0x1FB8, 0x1FBB, 0x1FBD, 0x1FC0, 0x1FC3, 0x1FC5, 0x1FC8, 0x1FCA, 0x1FCD, 0x1FCF, 0x1FD2, 0x1FD5, 0x1FD7, 0x1FDA, 0x1FDC, 0x1FDF, 0x1FE1, 0x1FE4, 0x1FE6, 0x1FE9, 0x1FEC, 0x1FEE, 0x1FF1, 0x1FF3, 0x1FF6, 0x1FF8, 0x1FFB, 0x1FFD, 0x2000, 0x2000, }; // Sines integer representation table for angle 0..90 degrees static const __int16 PhdSinTable[0x402] = { 0x0000, 0x0019, 0x0032, 0x004B, 0x0065, 0x007E, 0x0097, 0x00B0, 0x00C9, 0x00E2, 0x00FB, 0x0114, 0x012E, 0x0147, 0x0160, 0x0179, 0x0192, 0x01AB, 0x01C4, 0x01DD, 0x01F7, 0x0210, 0x0229, 0x0242, 0x025B, 0x0274, 0x028D, 0x02A6, 0x02C0, 0x02D9, 0x02F2, 0x030B, 0x0324, 0x033D, 0x0356, 0x036F, 0x0388, 0x03A1, 0x03BB, 0x03D4, 0x03ED, 0x0406, 0x041F, 0x0438, 0x0451, 0x046A, 0x0483, 0x049C, 0x04B5, 0x04CE, 0x04E7, 0x0500, 0x051A, 0x0533, 0x054C, 0x0565, 0x057E, 0x0597, 0x05B0, 0x05C9, 0x05E2, 0x05FB, 0x0614, 0x062D, 0x0646, 0x065F, 0x0678, 0x0691, 0x06AA, 0x06C3, 0x06DC, 0x06F5, 0x070E, 0x0727, 0x0740, 0x0759, 0x0772, 0x078B, 0x07A4, 0x07BD, 0x07D6, 0x07EF, 0x0807, 0x0820, 0x0839, 0x0852, 0x086B, 0x0884, 0x089D, 0x08B6, 0x08CF, 0x08E8, 0x0901, 0x0919, 0x0932, 0x094B, 0x0964, 0x097D, 0x0996, 0x09AF, 0x09C7, 0x09E0, 0x09F9, 0x0A12, 0x0A2B, 0x0A44, 0x0A5C, 0x0A75, 0x0A8E, 0x0AA7, 0x0AC0, 0x0AD8, 0x0AF1, 0x0B0A, 0x0B23, 0x0B3B, 0x0B54, 0x0B6D, 0x0B85, 0x0B9E, 0x0BB7, 0x0BD0, 0x0BE8, 0x0C01, 0x0C1A, 0x0C32, 0x0C4B, 0x0C64, 0x0C7C, 0x0C95, 0x0CAE, 0x0CC6, 0x0CDF, 0x0CF8, 0x0D10, 0x0D29, 0x0D41, 0x0D5A, 0x0D72, 0x0D8B, 0x0DA4, 0x0DBC, 0x0DD5, 0x0DED, 0x0E06, 0x0E1E, 0x0E37, 0x0E4F, 0x0E68, 0x0E80, 0x0E99, 0x0EB1, 0x0ECA, 0x0EE2, 0x0EFB, 0x0F13, 0x0F2B, 0x0F44, 0x0F5C, 0x0F75, 0x0F8D, 0x0FA5, 0x0FBE, 0x0FD6, 0x0FEE, 0x1007, 0x101F, 0x1037, 0x1050, 0x1068, 0x1080, 0x1099, 0x10B1, 0x10C9, 0x10E1, 0x10FA, 0x1112, 0x112A, 0x1142, 0x115A, 0x1173, 0x118B, 0x11A3, 0x11BB, 0x11D3, 0x11EB, 0x1204, 0x121C, 0x1234, 0x124C, 0x1264, 0x127C, 0x1294, 0x12AC, 0x12C4, 0x12DC, 0x12F4, 0x130C, 0x1324, 0x133C, 0x1354, 0x136C, 0x1384, 0x139C, 0x13B4, 0x13CC, 0x13E4, 0x13FB, 0x1413, 0x142B, 0x1443, 0x145B, 0x1473, 0x148B, 0x14A2, 0x14BA, 0x14D2, 0x14EA, 0x1501, 0x1519, 0x1531, 0x1549, 0x1560, 0x1578, 0x1590, 0x15A7, 0x15BF, 0x15D7, 0x15EE, 0x1606, 0x161D, 0x1635, 0x164C, 0x1664, 0x167C, 0x1693, 0x16AB, 0x16C2, 0x16DA, 0x16F1, 0x1709, 0x1720, 0x1737, 0x174F, 0x1766, 0x177E, 0x1795, 0x17AC, 0x17C4, 0x17DB, 0x17F2, 0x180A, 0x1821, 0x1838, 0x184F, 0x1867, 0x187E, 0x1895, 0x18AC, 0x18C3, 0x18DB, 0x18F2, 0x1909, 0x1920, 0x1937, 0x194E, 0x1965, 0x197C, 0x1993, 0x19AA, 0x19C1, 0x19D8, 0x19EF, 0x1A06, 0x1A1D, 0x1A34, 0x1A4B, 0x1A62, 0x1A79, 0x1A90, 0x1AA7, 0x1ABE, 0x1AD4, 0x1AEB, 0x1B02, 0x1B19, 0x1B30, 0x1B46, 0x1B5D, 0x1B74, 0x1B8A, 0x1BA1, 0x1BB8, 0x1BCE, 0x1BE5, 0x1BFC, 0x1C12, 0x1C29, 0x1C3F, 0x1C56, 0x1C6C, 0x1C83, 0x1C99, 0x1CB0, 0x1CC6, 0x1CDD, 0x1CF3, 0x1D0A, 0x1D20, 0x1D36, 0x1D4D, 0x1D63, 0x1D79, 0x1D90, 0x1DA6, 0x1DBC, 0x1DD3, 0x1DE9, 0x1DFF, 0x1E15, 0x1E2B, 0x1E42, 0x1E58, 0x1E6E, 0x1E84, 0x1E9A, 0x1EB0, 0x1EC6, 0x1EDC, 0x1EF2, 0x1F08, 0x1F1E, 0x1F34, 0x1F4A, 0x1F60, 0x1F76, 0x1F8C, 0x1FA2, 0x1FB7, 0x1FCD, 0x1FE3, 0x1FF9, 0x200F, 0x2024, 0x203A, 0x2050, 0x2065, 0x207B, 0x2091, 0x20A6, 0x20BC, 0x20D1, 0x20E7, 0x20FD, 0x2112, 0x2128, 0x213D, 0x2153, 0x2168, 0x217D, 0x2193, 0x21A8, 0x21BE, 0x21D3, 0x21E8, 0x21FE, 0x2213, 0x2228, 0x223D, 0x2253, 0x2268, 0x227D, 0x2292, 0x22A7, 0x22BC, 0x22D2, 0x22E7, 0x22FC, 0x2311, 0x2326, 0x233B, 0x2350, 0x2365, 0x237A, 0x238E, 0x23A3, 0x23B8, 0x23CD, 0x23E2, 0x23F7, 0x240B, 0x2420, 0x2435, 0x244A, 0x245E, 0x2473, 0x2488, 0x249C, 0x24B1, 0x24C5, 0x24DA, 0x24EF, 0x2503, 0x2518, 0x252C, 0x2541, 0x2555, 0x2569, 0x257E, 0x2592, 0x25A6, 0x25BB, 0x25CF, 0x25E3, 0x25F8, 0x260C, 0x2620, 0x2634, 0x2648, 0x265C, 0x2671, 0x2685, 0x2699, 0x26AD, 0x26C1, 0x26D5, 0x26E9, 0x26FD, 0x2711, 0x2724, 0x2738, 0x274C, 0x2760, 0x2774, 0x2788, 0x279B, 0x27AF, 0x27C3, 0x27D6, 0x27EA, 0x27FE, 0x2811, 0x2825, 0x2838, 0x284C, 0x2860, 0x2873, 0x2886, 0x289A, 0x28AD, 0x28C1, 0x28D4, 0x28E7, 0x28FB, 0x290E, 0x2921, 0x2935, 0x2948, 0x295B, 0x296E, 0x2981, 0x2994, 0x29A7, 0x29BB, 0x29CE, 0x29E1, 0x29F4, 0x2A07, 0x2A1A, 0x2A2C, 0x2A3F, 0x2A52, 0x2A65, 0x2A78, 0x2A8B, 0x2A9D, 0x2AB0, 0x2AC3, 0x2AD6, 0x2AE8, 0x2AFB, 0x2B0D, 0x2B20, 0x2B33, 0x2B45, 0x2B58, 0x2B6A, 0x2B7D, 0x2B8F, 0x2BA1, 0x2BB4, 0x2BC6, 0x2BD8, 0x2BEB, 0x2BFD, 0x2C0F, 0x2C21, 0x2C34, 0x2C46, 0x2C58, 0x2C6A, 0x2C7C, 0x2C8E, 0x2CA0, 0x2CB2, 0x2CC4, 0x2CD6, 0x2CE8, 0x2CFA, 0x2D0C, 0x2D1E, 0x2D2F, 0x2D41, 0x2D53, 0x2D65, 0x2D76, 0x2D88, 0x2D9A, 0x2DAB, 0x2DBD, 0x2DCF, 0x2DE0, 0x2DF2, 0x2E03, 0x2E15, 0x2E26, 0x2E37, 0x2E49, 0x2E5A, 0x2E6B, 0x2E7D, 0x2E8E, 0x2E9F, 0x2EB0, 0x2EC2, 0x2ED3, 0x2EE4, 0x2EF5, 0x2F06, 0x2F17, 0x2F28, 0x2F39, 0x2F4A, 0x2F5B, 0x2F6C, 0x2F7D, 0x2F8D, 0x2F9E, 0x2FAF, 0x2FC0, 0x2FD0, 0x2FE1, 0x2FF2, 0x3002, 0x3013, 0x3024, 0x3034, 0x3045, 0x3055, 0x3066, 0x3076, 0x3087, 0x3097, 0x30A7, 0x30B8, 0x30C8, 0x30D8, 0x30E8, 0x30F9, 0x3109, 0x3119, 0x3129, 0x3139, 0x3149, 0x3159, 0x3169, 0x3179, 0x3189, 0x3199, 0x31A9, 0x31B9, 0x31C8, 0x31D8, 0x31E8, 0x31F8, 0x3207, 0x3217, 0x3227, 0x3236, 0x3246, 0x3255, 0x3265, 0x3274, 0x3284, 0x3293, 0x32A3, 0x32B2, 0x32C1, 0x32D0, 0x32E0, 0x32EF, 0x32FE, 0x330D, 0x331D, 0x332C, 0x333B, 0x334A, 0x3359, 0x3368, 0x3377, 0x3386, 0x3395, 0x33A3, 0x33B2, 0x33C1, 0x33D0, 0x33DF, 0x33ED, 0x33FC, 0x340B, 0x3419, 0x3428, 0x3436, 0x3445, 0x3453, 0x3462, 0x3470, 0x347F, 0x348D, 0x349B, 0x34AA, 0x34B8, 0x34C6, 0x34D4, 0x34E2, 0x34F1, 0x34FF, 0x350D, 0x351B, 0x3529, 0x3537, 0x3545, 0x3553, 0x3561, 0x356E, 0x357C, 0x358A, 0x3598, 0x35A5, 0x35B3, 0x35C1, 0x35CE, 0x35DC, 0x35EA, 0x35F7, 0x3605, 0x3612, 0x3620, 0x362D, 0x363A, 0x3648, 0x3655, 0x3662, 0x366F, 0x367D, 0x368A, 0x3697, 0x36A4, 0x36B1, 0x36BE, 0x36CB, 0x36D8, 0x36E5, 0x36F2, 0x36FF, 0x370C, 0x3718, 0x3725, 0x3732, 0x373F, 0x374B, 0x3758, 0x3765, 0x3771, 0x377E, 0x378A, 0x3797, 0x37A3, 0x37B0, 0x37BC, 0x37C8, 0x37D5, 0x37E1, 0x37ED, 0x37F9, 0x3805, 0x3812, 0x381E, 0x382A, 0x3836, 0x3842, 0x384E, 0x385A, 0x3866, 0x3871, 0x387D, 0x3889, 0x3895, 0x38A1, 0x38AC, 0x38B8, 0x38C3, 0x38CF, 0x38DB, 0x38E6, 0x38F2, 0x38FD, 0x3909, 0x3914, 0x391F, 0x392B, 0x3936, 0x3941, 0x394C, 0x3958, 0x3963, 0x396E, 0x3979, 0x3984, 0x398F, 0x399A, 0x39A5, 0x39B0, 0x39BB, 0x39C5, 0x39D0, 0x39DB, 0x39E6, 0x39F0, 0x39FB, 0x3A06, 0x3A10, 0x3A1B, 0x3A25, 0x3A30, 0x3A3A, 0x3A45, 0x3A4F, 0x3A59, 0x3A64, 0x3A6E, 0x3A78, 0x3A82, 0x3A8D, 0x3A97, 0x3AA1, 0x3AAB, 0x3AB5, 0x3ABF, 0x3AC9, 0x3AD3, 0x3ADD, 0x3AE6, 0x3AF0, 0x3AFA, 0x3B04, 0x3B0E, 0x3B17, 0x3B21, 0x3B2A, 0x3B34, 0x3B3E, 0x3B47, 0x3B50, 0x3B5A, 0x3B63, 0x3B6D, 0x3B76, 0x3B7F, 0x3B88, 0x3B92, 0x3B9B, 0x3BA4, 0x3BAD, 0x3BB6, 0x3BBF, 0x3BC8, 0x3BD1, 0x3BDA, 0x3BE3, 0x3BEC, 0x3BF5, 0x3BFD, 0x3C06, 0x3C0F, 0x3C17, 0x3C20, 0x3C29, 0x3C31, 0x3C3A, 0x3C42, 0x3C4B, 0x3C53, 0x3C5B, 0x3C64, 0x3C6C, 0x3C74, 0x3C7D, 0x3C85, 0x3C8D, 0x3C95, 0x3C9D, 0x3CA5, 0x3CAD, 0x3CB5, 0x3CBD, 0x3CC5, 0x3CCD, 0x3CD5, 0x3CDD, 0x3CE4, 0x3CEC, 0x3CF4, 0x3CFB, 0x3D03, 0x3D0B, 0x3D12, 0x3D1A, 0x3D21, 0x3D28, 0x3D30, 0x3D37, 0x3D3F, 0x3D46, 0x3D4D, 0x3D54, 0x3D5B, 0x3D63, 0x3D6A, 0x3D71, 0x3D78, 0x3D7F, 0x3D86, 0x3D8D, 0x3D93, 0x3D9A, 0x3DA1, 0x3DA8, 0x3DAF, 0x3DB5, 0x3DBC, 0x3DC2, 0x3DC9, 0x3DD0, 0x3DD6, 0x3DDD, 0x3DE3, 0x3DE9, 0x3DF0, 0x3DF6, 0x3DFC, 0x3E03, 0x3E09, 0x3E0F, 0x3E15, 0x3E1B, 0x3E21, 0x3E27, 0x3E2D, 0x3E33, 0x3E39, 0x3E3F, 0x3E45, 0x3E4A, 0x3E50, 0x3E56, 0x3E5C, 0x3E61, 0x3E67, 0x3E6C, 0x3E72, 0x3E77, 0x3E7D, 0x3E82, 0x3E88, 0x3E8D, 0x3E92, 0x3E98, 0x3E9D, 0x3EA2, 0x3EA7, 0x3EAC, 0x3EB1, 0x3EB6, 0x3EBB, 0x3EC0, 0x3EC5, 0x3ECA, 0x3ECF, 0x3ED4, 0x3ED8, 0x3EDD, 0x3EE2, 0x3EE7, 0x3EEB, 0x3EF0, 0x3EF4, 0x3EF9, 0x3EFD, 0x3F02, 0x3F06, 0x3F0A, 0x3F0F, 0x3F13, 0x3F17, 0x3F1C, 0x3F20, 0x3F24, 0x3F28, 0x3F2C, 0x3F30, 0x3F34, 0x3F38, 0x3F3C, 0x3F40, 0x3F43, 0x3F47, 0x3F4B, 0x3F4F, 0x3F52, 0x3F56, 0x3F5A, 0x3F5D, 0x3F61, 0x3F64, 0x3F68, 0x3F6B, 0x3F6E, 0x3F72, 0x3F75, 0x3F78, 0x3F7B, 0x3F7F, 0x3F82, 0x3F85, 0x3F88, 0x3F8B, 0x3F8E, 0x3F91, 0x3F94, 0x3F97, 0x3F99, 0x3F9C, 0x3F9F, 0x3FA2, 0x3FA4, 0x3FA7, 0x3FAA, 0x3FAC, 0x3FAF, 0x3FB1, 0x3FB4, 0x3FB6, 0x3FB8, 0x3FBB, 0x3FBD, 0x3FBF, 0x3FC1, 0x3FC4, 0x3FC6, 0x3FC8, 0x3FCA, 0x3FCC, 0x3FCE, 0x3FD0, 0x3FD2, 0x3FD4, 0x3FD5, 0x3FD7, 0x3FD9, 0x3FDB, 0x3FDC, 0x3FDE, 0x3FE0, 0x3FE1, 0x3FE3, 0x3FE4, 0x3FE6, 0x3FE7, 0x3FE8, 0x3FEA, 0x3FEB, 0x3FEC, 0x3FED, 0x3FEF, 0x3FF0, 0x3FF1, 0x3FF2, 0x3FF3, 0x3FF4, 0x3FF5, 0x3FF6, 0x3FF7, 0x3FF7, 0x3FF8, 0x3FF9, 0x3FFA, 0x3FFA, 0x3FFB, 0x3FFC, 0x3FFC, 0x3FFD, 0x3FFD, 0x3FFE, 0x3FFE, 0x3FFE, 0x3FFF, 0x3FFF, 0x3FFF, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, }; int __fastcall phd_atan(int x, int y) { int result; int swapBuf; int flags = 0; if( x == 0 && y == 0 ) return 0; if( x < 0 ) { flags |= 4; x = -x; } if( y < 0 ) { flags |= 2; y = -y; } if( y > x ) { flags |= 1; SWAP(x, y, swapBuf); } result = AtanBaseTable[flags] + AtanAngleTable[0x800*y/x]; if ( result < 0 ) result = -result; return result; } int __fastcall phd_cos(__int16 angle) { return phd_sin(angle + PHD_90); } int __fastcall phd_sin(__int16 angle) { UINT16 sector = (UINT16)angle & (PHD_180-1); // sector range will be: 0..0x7FFF (0..179.99 degrees) if( sector > PHD_90 ) sector = PHD_180 - sector; // sector range will be: 0x0000..0x4000 (0..90 degrees) int result = PhdSinTable[sector/16]; if( (UINT16)angle >= PHD_180 ) result = -result; return result; } DWORD __fastcall phd_sqrt(DWORD n) { DWORD result = 0; DWORD base = 0x40000000; DWORD basedResult; for( ; base != 0; base >>= 2 ) { for( ; base != 0; base >>= 2 ) { basedResult = base + result; result >>= 1; if( basedResult > n ) { break; } n -= basedResult; result |= base; } } return result; } /* * Inject function */ void Inject_PhdMath() { INJECT(0x00457EA0, phd_atan); INJECT(0x00457EE8, phd_cos); INJECT(0x00457EEE, phd_sin); INJECT(0x00457F23, phd_sqrt); } ================================================ FILE: 3dsystem/phd_math.h ================================================ /* * Copyright (c) 2017-2018 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #ifndef PHD_MATH_H_INCLUDED #define PHD_MATH_H_INCLUDED #include "global/types.h" /* * Function list */ int __fastcall phd_atan(int x, int y); // 0x00457EA0 int __fastcall phd_cos(__int16 angle); // 0x00457EE8 int __fastcall phd_sin(__int16 angle); // 0x00457EEE DWORD __fastcall phd_sqrt(DWORD n); // 0x00457F23 #endif // PHD_MATH_H_INCLUDED ================================================ FILE: 3dsystem/scalespr.cpp ================================================ /* * Copyright (c) 2017-2020 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #include "global/precompiled.h" #include "3dsystem/scalespr.h" #include "specific/output.h" #include "global/vars.h" #ifdef FEATURE_VIEW_IMPROVED extern int CalculateFogShade(int depth); #endif // FEATURE_VIEW_IMPROVED #ifdef FEATURE_VIDEOFX_IMPROVED DWORD PickupItemMode = 1; #endif // FEATURE_VIDEOFX_IMPROVED void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, __int16 shade, __int16 scale) { int xv, yv, zv, zp, depth; int x1, y1, x2, y2; if( CHK_ANY(flags, SPR_ABS) ) { // absolute coords x -= MatrixW2V._03; y -= MatrixW2V._13; z -= MatrixW2V._23; if( x < -PhdViewDistance || x > PhdViewDistance ) return; if( y < -PhdViewDistance || y > PhdViewDistance) return; if( z < -PhdViewDistance || z > PhdViewDistance) return; zv = MatrixW2V._20 * x + MatrixW2V._21 * y + MatrixW2V._22 * z; if( zv < PhdNearZ || zv >= PhdFarZ ) return; yv = MatrixW2V._10 * x + MatrixW2V._11 * y + MatrixW2V._12 * z; xv = MatrixW2V._00 * x + MatrixW2V._01 * y + MatrixW2V._02 * z; } else if( (x|y|z) == 0 ) { // zero point coords zv = PhdMatrixPtr->_23; if( zv < PhdNearZ || zv > PhdFarZ ) return; yv = PhdMatrixPtr->_13; xv = PhdMatrixPtr->_03; } else { // relative coords zv = PhdMatrixPtr->_20 * x + PhdMatrixPtr->_21 * y + PhdMatrixPtr->_22 * z + PhdMatrixPtr->_23; if( zv < PhdNearZ || zv > PhdFarZ ) return; yv = PhdMatrixPtr->_10 * x + PhdMatrixPtr->_11 * y + PhdMatrixPtr->_12 * z + PhdMatrixPtr->_13; xv = PhdMatrixPtr->_00 * x + PhdMatrixPtr->_01 * y + PhdMatrixPtr->_02 * z + PhdMatrixPtr->_03; } x1 = PhdSpriteInfo[spriteIdx].x1; y1 = PhdSpriteInfo[spriteIdx].y1; x2 = PhdSpriteInfo[spriteIdx].x2; y2 = PhdSpriteInfo[spriteIdx].y2; #ifdef FEATURE_VIDEOFX_IMPROVED if( PickupItemMode == 1 && CHK_ALL(flags, SPR_ITEM|SPR_ABS) ) { if( y1 < y2 ) { y1 -= y2; y2 = 0; } else { y2 -= y1; y1 = 0; } } #endif // FEATURE_VIDEOFX_IMPROVED if( CHK_ANY(flags, SPR_SCALE) ) { // scaling required x1 = (x1 * scale) << (W2V_SHIFT - 8); y1 = (y1 * scale) << (W2V_SHIFT - 8); x2 = (x2 * scale) << (W2V_SHIFT - 8); y2 = (y2 * scale) << (W2V_SHIFT - 8); } else { // default scale x1 <<= W2V_SHIFT; y1 <<= W2V_SHIFT; x2 <<= W2V_SHIFT; y2 <<= W2V_SHIFT; } zp = zv / PhdPersp; x1 = (x1 + xv) / zp + PhdWinCenterX; if( x1 >= PhdWinWidth ) return; y1 = (y1 + yv) / zp + PhdWinCenterY; if( y1 >= PhdWinHeight ) return; x2 = (x2 + xv) / zp + PhdWinCenterX; if( x2 < 0 ) return; y2 = (y2 + yv) / zp + PhdWinCenterY; if( y2 < 0 ) return; if( CHK_ANY(flags, SPR_SHADE) ) { // shading required depth = zv >> W2V_SHIFT; #ifdef FEATURE_VIEW_IMPROVED if( depth > PhdViewDistance ) return; shade += CalculateFogShade(depth); CLAMP(shade, 0, 0x1FFF); #else // !FEATURE_VIEW_IMPROVED if( depth > DEPTHQ_START ) { shade += depth - DEPTHQ_START; if( shade > 0x1FFF ) { return; } } #endif // FEATURE_VIEW_IMPROVED } else { shade = 0x1000; } #ifdef FEATURE_VIDEOFX_IMPROVED if( CHK_ANY(flags, SPR_TINT) && !CHK_ANY(flags, SPR_SHADE) ) { // NOTE: PS1 tint color brightness must be multiplied by 2 in this case shade = (shade > 0x1000) ? (shade-0x1000)*2 : 0; } ins_sprite(zv, x1, y1, x2, y2, spriteIdx, shade, flags); #else // FEATURE_VIDEOFX_IMPROVED ins_sprite(zv, x1, y1, x2, y2, spriteIdx, shade); #endif // FEATURE_VIDEOFX_IMPROVED } void __cdecl S_DrawPickup(int sx, int sy, int scale, __int16 spriteIdx, __int16 shade) { int x1, x2, y1, y2; #ifdef FEATURE_HUD_IMPROVED scale = GetRenderScale(scale); #endif // FEATURE_HUD_IMPROVED x1 = sx + (PhdSpriteInfo[spriteIdx].x1 * scale / PHD_ONE); x2 = sx + (PhdSpriteInfo[spriteIdx].x2 * scale / PHD_ONE); y1 = sy + (PhdSpriteInfo[spriteIdx].y1 * scale / PHD_ONE); y2 = sy + (PhdSpriteInfo[spriteIdx].y2 * scale / PHD_ONE); if( x2 >= 0 && y2 >= 0 && x1 < PhdWinWidth && y1 < PhdWinHeight ) { #ifdef FEATURE_VIDEOFX_IMPROVED ins_sprite(200, x1, y1, x2, y2, spriteIdx, shade, 0); #else // FEATURE_VIDEOFX_IMPROVED ins_sprite(200, x1, y1, x2, y2, spriteIdx, shade); #endif // FEATURE_VIDEOFX_IMPROVED } } __int16 *__cdecl ins_room_sprite(__int16 *ptrObj, int vtxCount) { PHD_VBUF *vbuf; PHD_SPRITE *sprite; double zp; int x1, y1, x2, y2; for( int i = 0; i < vtxCount; ++i ) { vbuf = &PhdVBuf[*ptrObj]; if( (vbuf->clip & 0x80) == 0 ) { sprite = &PhdSpriteInfo[ptrObj[1]]; zp = (double)vbuf->zv / (double)PhdPersp; x1 = (int)((vbuf->xv + (double)((int)sprite->x1 << W2V_SHIFT)) / zp) + PhdWinCenterX; y1 = (int)((vbuf->yv + (double)((int)sprite->y1 << W2V_SHIFT)) / zp) + PhdWinCenterY; x2 = (int)((vbuf->xv + (double)((int)sprite->x2 << W2V_SHIFT)) / zp) + PhdWinCenterX; y2 = (int)((vbuf->yv + (double)((int)sprite->y2 << W2V_SHIFT)) / zp) + PhdWinCenterY; if( x2 >= PhdWinLeft && y2 >= PhdWinTop && x1 < PhdWinRight && y1 < PhdWinBottom ) { #ifdef FEATURE_VIDEOFX_IMPROVED ins_sprite((int)vbuf->zv, x1, y1, x2, y2, ptrObj[1], vbuf->g, 0); #else // FEATURE_VIDEOFX_IMPROVED ins_sprite((int)vbuf->zv, x1, y1, x2, y2, ptrObj[1], vbuf->g); #endif // FEATURE_VIDEOFX_IMPROVED } } ptrObj += 2; } return ptrObj; } void __cdecl S_DrawScreenSprite2d(int sx, int sy, int sz, int scaleH, int scaleV, __int16 spriteIdx, __int16 shade, UINT16 flags) { int x1, y1, x2, y2, z; PHD_SPRITE *sprite = &PhdSpriteInfo[spriteIdx]; x1 = sx + sprite->x1 * scaleH / PHD_ONE; y1 = sy + sprite->y1 * scaleV / PHD_ONE; x2 = sx + sprite->x2 * scaleH / PHD_ONE; y2 = sy + sprite->y2 * scaleV / PHD_ONE; z = PhdNearZ + sz * 8; if( x2 >= 0 && y2 >= 0 && x1 < PhdWinWidth && y1 < PhdWinHeight ) { #ifdef FEATURE_VIDEOFX_IMPROVED ins_sprite(z, x1, y1, x2, y2, spriteIdx, shade, 0); #else // FEATURE_VIDEOFX_IMPROVED ins_sprite(z, x1, y1, x2, y2, spriteIdx, shade); #endif // FEATURE_VIDEOFX_IMPROVED } } void __cdecl S_DrawScreenSprite(int sx, int sy, int sz, int scaleH, int scaleV, __int16 spriteIdx, __int16 shade, UINT16 flags) { int x1, y1, x2, y2, z; PHD_SPRITE *sprite = &PhdSpriteInfo[spriteIdx]; x1 = sx + (sprite->x1 / 8) * scaleH / PHD_ONE; y1 = sy + (sprite->y1 / 8) * scaleV / PHD_ONE; x2 = sx + (sprite->x2 / 8) * scaleH / PHD_ONE; y2 = sy + (sprite->y2 / 8) * scaleV / PHD_ONE; z = sz * 8; if( x2 >= 0 && y2 >= 0 && x1 < PhdWinWidth && y1 < PhdWinHeight ) { #ifdef FEATURE_VIDEOFX_IMPROVED ins_sprite(z, x1, y1, x2, y2, spriteIdx, shade, 0); #else // FEATURE_VIDEOFX_IMPROVED ins_sprite(z, x1, y1, x2, y2, spriteIdx, shade); #endif // FEATURE_VIDEOFX_IMPROVED } } void __cdecl draw_scaled_spriteC(__int16 *ptrObj) { #ifdef FEATURE_NOLEGACY_OPTIONS extern int GetPitchSWR(); int pitch = GetPitchSWR(); #else // FEATURE_NOLEGACY_OPTIONS int pitch = PhdScreenWidth; // NOTE: this is the original game bug! #endif // FEATURE_NOLEGACY_OPTIONS int i, j; int x1, y1, x2, y2, width, height; int u, uBase, vBase, uAdd, vAdd; __int16 sprIdx, shade; BYTE *srcBase, *src, *dst; BYTE pix; int dstAdd; bool isDepthQ; PHD_SPRITE *sprite; DEPTHQ_ENTRY *depthQ; x1 = ptrObj[0]; y1 = ptrObj[1]; x2 = ptrObj[2]; y2 = ptrObj[3]; sprIdx = ptrObj[4]; shade = ptrObj[5]; if( x1 >= x2 || y1 >= y2 || x2 <= 0 || y2 <= 0 || x1 >= PhdWinMaxX || y1 >= PhdWinMaxY ) return; sprite = &PhdSpriteInfo[sprIdx]; depthQ = &DepthQTable[shade >> 8]; uBase = vBase = 0x4000; uAdd = (sprite->width - 64) * 256 / (x2 - x1); vAdd = (sprite->height - 64) * 256 / (y2 - y1); if( x1 < 0 ) { uBase -= uAdd * x1; x1 = 0; } if( y1 < 0 ) { vBase -= vAdd * y1; y1 = 0; } CLAMPG(x2, PhdWinMaxX + 1); CLAMPG(y2, PhdWinMaxY + 1); width = x2 - x1; height = y2 - y1; srcBase = (BYTE *)TexturePageBuffer8[sprite->texPage] + sprite->offset; dst = PrintSurfacePtr + (PhdWinMinY + y1) * pitch + (PhdWinMinX + x1); dstAdd = pitch - width; #if (DIRECT3D_VERSION >= 0x900) isDepthQ = (depthQ != &DepthQTable[15]); #else // (DIRECT3D_VERSION >= 0x900) isDepthQ = (GameVid_IsWindowedVga || depthQ != &DepthQTable[15]); // NOTE: index was 16 in the original code, this was wrong #endif // (DIRECT3D_VERSION >= 0x900) for( i = 0; i < height; ++i ) { u = uBase; src = srcBase + (vBase >> 16) * 256; for( j = 0; j < width; ++j ) { pix = src[u >> 16]; if( pix != 0 ) { *dst = ( isDepthQ ) ? depthQ->index[pix] : pix; } u += uAdd; ++dst; } dst += dstAdd; vBase += vAdd; } } /* * Inject function */ void Inject_ScaleSpr() { INJECT(0x0040C030, S_DrawSprite); INJECT(0x0040C300, S_DrawPickup); INJECT(0x0040C390, ins_room_sprite); INJECT(0x0040C4F0, S_DrawScreenSprite2d); INJECT(0x0040C590, S_DrawScreenSprite); INJECT(0x0040C630, draw_scaled_spriteC); } ================================================ FILE: 3dsystem/scalespr.h ================================================ /* * Copyright (c) 2017-2018 Michael Chaban. All rights reserved. * Original game is created by Core Design Ltd. in 1997. * Lara Croft and Tomb Raider are trademarks of Embracer Group AB. * * This file is part of TR2Main. * * TR2Main is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TR2Main is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TR2Main. If not, see . */ #ifndef SCALESPR_H_INCLUDED #define SCALESPR_H_INCLUDED #include "global/types.h" /* * Function list */ void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, __int16 shade, __int16 scale); // 0x0040C030 void __cdecl S_DrawPickup(int sx, int sy, int scale, __int16 spriteIdx, __int16 shade); // 0x0040C300 __int16 *__cdecl ins_room_sprite(__int16 *ptrObj, int vtxCount); // 0x0040C390 void __cdecl S_DrawScreenSprite2d(int sx, int sy, int sz, int scaleH, int scaleV, __int16 spriteIdx, __int16 shade, UINT16 flags); // 0x0040C4F0 void __cdecl S_DrawScreenSprite(int sx, int sy, int sz, int scaleH, int scaleV, __int16 spriteIdx, __int16 shade, UINT16 flags); // 0x0040C590 void __cdecl draw_scaled_spriteC(__int16 *ptrObj); // 0x0040C630 #endif // SCALESPR_H_INCLUDED ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ## [0.9.0] - 2023-06-05 ### New features - The Golden Mask game is included into a release pack, since it's freeware. The original game level files must be officially obtained via Steam/GOG/CD/whatever. - Added DirectX 9 support. However, TR2Main can be compiled for DirectX 5 too. - Into TR2Main.dll added information about the current version. Now it will be easier to find out which DLL is which version. - The number of secrets in the script is taken into account when calculating the total number of secrets in the final statistics. Now it is calculated correctly, regardless of the total number of levels, bonus levels, and even mod levels. - Additional checks have been implemented to prevent Lara from getting weapons that are not supported by current level. Thus, a number of problems associated with the "Nightmare in Vegas" level are fixed. - Now *"New Game+"* is activated after the completion of the latest level in the script, and not any in which the final statistics appear. This allows you to activate this mode after the "Nightmare in Vegas" level, and not before. - Now you can start the game in Gold mode, specifying the option *"-gold"* on the command line or shortcut properties (in the same way as the *"-setup"* option). - For the Gold mode, Spider and Big Spider AI replaced by Wolf and Bear AI. Also Monk Spirits have no shadow. - For the Gold mode, the credits slideshow starts from *CREDIT00.PCX*. For the original game mode, it starts from *CREDIT01.PCX*. - For the Gold mode, the selection of any levels (including bonus levels) is activated after collecting all the secrets (available before the final statistics). The ability to select levels remains even after relaunching the game. - For the Gold mode, pictures with "g" filename suffix (TITLEg.PCX, LEGALg.PCX, etc.) have higher priority than pictures without "g" filename suffix (TITLE.PCX, LEGAL.PCX, etc.) - For the Gold mode, instead of the files *"TOMBPC.DAT"* and *"MAIN.SFX"*, the files *"TOMBPCg.DAT"* and *"MAINg.SFX"* are used. However, for both Gold and the original game, *"MAIN.SFX"* is still used for the *"TITLE.TR2"* and *"ASSAULT.TR2"* levels. - Added separate subfolders for saved games of Gold and the original game. - Added PlayStation reflection visual effect. - Z-Buffer is no longer required for PlayStation styled gradient health/air bars. - Added basic/advanced alpha blending for PlayStation styled semitransparent effects. - Added glow effect for gunfire/flare (alpha blending required). - Most sprites, gunfire/flare effects, sunglasses lens, the dragon spheres of doom are made semitransparent (alpha blending required). This is how they look in the PlayStation version. - Rolling wheel blades, wall mounted blades, swords of statues and flamethrower masks are made reflective. This is how they look in the PlayStation version. - The armed snowmobile windshield is made reflective. This is not presented in the PlayStation version, but probably it was supposed to be. Anyway it looks cool! - The original game fast snowmobile windshield is made semitransparent (alpha blending required). This is how it looks in the PlayStation version. - The Golden Mask fast snowmobile windshield is made reflective. In the Golden Mask it has the same windshield model as the armed snowmobile. - Boathouse Key and Library Key from Venice levels are made reflective. This is how they look in the PlayStation version. - The water surfaces and the glass on the sink in Lara's bathroom are made semitransparent (alpha blending required). This is how they look in the PlayStation version. - Chain-link fence texture from Venice levels and stained glass texture from "Wreck of the Maria Doria" level are made semitransparent (alpha blending required). This is how they look in the PlayStation version. - The glass on the sink in the "Nightmare in Vegas" level is made semitransparent (alpha blending required). - Added support for loading screens from the script. - Added TR2Main.json configuration file for easy game modding in the future. - Added support for loading screens from TR2Main.json configuration file. - Added support for custom water color from TR2Main.json configuration file. - Added support for barefoot steps SFX from TR2Main.json configuration file (BAREFOOT.SFX in the DATA folder required). - Added support for Legal/Title pictures with both US/EU logo (just a simple option to toggle between logo versions). - Remastered pictures (PNG/JPG/BMP) support can be disabled now. In this case the game will use only PCX pictures. - Custom HUD scale can be set to any value in 0.5 - 2.0 (previously it was limited by 1.0 - 2.0). - Added support for display resolutions higher than 2048x2048. - Background picture code is redesigned to support resolutions higher than 2048x2048. - The limitations of the game engine (textures, polygons) are expanded by 4 times for future TR2 mods. - Added music mute settings for inventory/underwater. - The music and cut scenes are paused when the game window is not active. - Added options for level statistics background mode (hardware renderer required). - Added full inventory cheat on *I* key (cheat flag in *"TOMBPC.DAT"* file required). It gives full health, all weapons, ammo, medipacks, flares and all keys. - Added Dozy cheat on *O* key (cheat flag in *"TOMBPC.DAT"* file required). It gives fly mode and full health, use *Shift* key to disable it. - Lara has golden skin while in Dozy mode (hardware renderer and reflection feature required). - SFX number limit increased from 256 to 370. - Added automatic cdaudio.dat fix for PaulD's CD Audio solution, if some track has wrong parameters (like in the Steam version). - Added possibility to customize semitransparent/reflective polygons via TR2Main.json configuration file. - Added the ability to side step hitting the *Left*/*Right* key while holding *Walk* key (optional feature). - Added possibility to hold up/down keys to quickly scroll through game menus. - Added a configurable number of saved game slots (16-24). - Joystick support completely migrated from WinAPI to DirectInput. Added XInput controllers support. Added DualShock 4 / DualSense support. - Joystick controls redesigned to use thumb sticks and D-Pad at the same time. - Added vibration feedback support for XInput gamepads and DualShock 4 / DualSense. - Added the light bar color feedback support for DualShock 4 / DualSense. The color changes depending from health and oxygen. - Passport text box height is adjusted depending from HUD scale. - Some legacy options are removed (Triple Buffer, Dither, Perspective Correction, Texel Adjustment, Disable 16 bit textures, Don't sort transparent polys). - Screen resolution settings reworked, now the game automatically selects between True Color / High Color. - Now the game correctly keeps proper resolutions when it switches between Windowed / Full Screen. - Implemented embedded textures for Keyboard/Joystick button sprites. There are 3 styles for Joystick buttons: Numeric, XBox, PlayStation. - Added arrows to PlayStation styled inventory text boxes. - Sound/Music volumes presented as gradient bars if PlayStation styled inventory text boxes are enabled. Also there are PlayStation styled SFX for changing volume. - Added PlayStation styled Joystick button hints for inventory (optional feature). - Added Pause feature (P key). Two styles are available: transparent and 50% darkened. - Controls text box completely redesigned. Now you can view both default and custom keyboard layouts on the same page. Joystick layout is now independent from the custom keyboard layout. - Fade out to black implemented for levels, demos, cut scenes and statistics. - Added an option to select Demo Mode text style: none, PC or PlayStation. - Now the inventory stopwatch (statistics item) position depends from HUD scale and Field of View options. So it looks both PlayStation and PC authentic. - The message is displayed when Bilinear Filter or Z-Buffer is toggled with F7/F8 hotkey (DirectX 9 only). - Added high contrast lighting (PlayStation style) for Hardware Renderer (DirectX 9 only). - Added low contrast lighting (Classic PC Hardware style) for Software Renderer. - Added F11 hotkey to toggle low/high contrast lighting (in the original game F11 was used to toggle Dither). - Sunset effect in Bartoli's Hideout now makes skybox a little darker. - Added "Restart Level" option (available only in case of Lara's death). - The inventory pattern (both static and animated) is seamless now for Bilinear Filter. - Added external HD textures support (DirectX 9 only). - Added iOS/Android texture pack full support (DirectX 9 only). - Added ffmpeg based FMV player. - Added loading screens by Lito Perezito for The Golden Mask. ### The original game bugfixes - Fixed a bug that prevented the display of the save counter until the game relaunch, if the game was saved in an empty slot. - Fixed a bug that allowed the player to interfere with the control of the demo level. - Demo levels are excluded from the *"New Game"* menu, if the *"Select Level"* option is active. - Fixed the statistics reset in case of *"New Game+"*, if the *"Select Level"* option is active. - Fixed a bug that does not happen in the official levels (this situation is not in the script). Suppose a shotgun and shotgun ammo are set as a bonus for collecting all the secrets in the level. If Lara does not have a shotgun at the moment of picking the last secret, she receives the relying bonus, but the ammo items are not displayed on the screen. This is fixed now. - Fixed a bug that does not happen in the official levels (this situation is not in the script). Suppose a magnum and magnum ammo are set as a bonus for collecting all the secrets in the level. If Lara does not have a magnum at the moment of picking the last secret, she receives the magnum only, but not the magnum ammo. This is fixed now. - Fixed a bug that hid the ammo indicator in demo levels if *"New Game+"* is activated. - Fixed a bug that produced black triangles originating from the top left of the screen on some laptop graphic adapters. - Fixed a bug that produced traces of previous textures in untextured areas. - If "Disable 16 bit textures" option is unsupported, it's disabled automatically instead of breaking the textures. - Fixed a bug that changed the music volume incorrectly when leaving inventory while the camera is underwater. - Fixed a rare game crash occurring when you explode an enemy with a grenade launcher. - Fixed incorrect sorting of 3D polygons if Z-Buffer is turned off or the software renderer is used. - Fixed a bug due to which the skybox was not drawn in some rooms. - Fixed a bug where pickup sprites were cropped by the floor if Z-Buffer is enabled. Some pickup items are slightly raised (optional fix). - Fixed a bug due to which the last pressed key was accidentally assigned when redefining keys. - "Run Control Panel" button in the setup dialog now opens the current DirectInput joystick configuration from Control Panel instead of Control Panel itself. - Fixed a bug that caused the harpoon gun to reload every single shot in *"New Game+"* after a weapon cheat was used. - Fixed a bug due to which none of the joystick buttons allowed returning to the previous menu. Now the button assigned to "Draw weapon" is used for this. - Fixed a bug due to which the accuracy of the M16 did not decrease while running (optional fix). - Fixed a wrong inventory text position if the game window size is changed. - Fixed a flashing "Demo Mode" text while demo is playing. - The *low ceiling jump* bugfix is optional now. - Fixed a bug due to which non-textured surfaces could appear brighter than textured ones with the same lighting settings. - Fixed a bug that reset timer of sunset effect in Bartoli's Hideout after saved game is loaded. ### TR2Main bugfixes - Background capture is optimized even more, now it is 3-4 times faster than v0.8.2. No lags anymore (broken since v0.8.0). - Fixed game crash in Software Rendered mode with PlayStation styled inventory text box enabled (broken since v0.8.0). - Fixed a rare game crash occurring when launching the game (broken since v0.1.0). - Fixed sunset effect in Bartoli's Hideout level (broken since v0.1.0). - Fixed texel adjustment if the filtering is changed by *F8* hotkey while "Adjust when bilinear filtering" option is enabled (broken since v0.1.0). - Now the PaulD's CD Audio is paused when the music volume is set to 0. This is how real CD Audio works (broken since v0.2.0). - Fixed "Gosh! That was my best time yet!" phrase in the case if it's a first try after game launch, but the time is not the best at all (broken since v0.5.0). - Fixed a bug when some underwater objects were untinted (broken since v0.1.0). - Fixed camera stabilization in some cut scenes (broken since v0.1.0). - Fixed the "Microphone Position at Lara" setting (broken since v0.1.0). - Changed randomizer formula to be less correct, but consistent with the original game (broken since v0.1.0). ## [0.8.2] - 2019-05-26 ### TR2Main bugfixes - Background capture is redesigned, now it's fast again (broken since v0.8.0). - Background capture is processed only when required (broken since v0.8.0). - Fixed PlayStation styled field of view (broken since v0.8.0). ## [0.8.1] - 2018-10-21 ### The original game bugfixes - Fixed texture corruption after FMV scenes. - Fixed the game hangup if the game window is closed on the statistics screen. ### TR2Main bugfixes - Level statistics background properly fades out now (broken since v0.8.0). ## [0.8.0] - 2018-09-25 ### New features - Added automatic blocking of incompatible video modes that caused the game to crash. - The resolution limit is set to 2048x2048, since DirectX 5 cannot handle more. - Changed the default aspect ratio from 1:1 to 4:3 for the windowed mode with the "any aspect" in the setup dialog. - Added possibility to use up to 99 images in the credits slideshow. The original game limit is 9 images. - Added support for HD PCX images (up to 2048x2048). The original game supported only 640x480 images. - Added stretch limit control for background picture (optional feature). - Added PNG/JPEG/BMP images support (hardware renderer required). - Added *PIX* folder for automatic management of pictures with different aspect ratios. - Added PNG screenshots with date-time filename format (optional feature). TGA/PCX screenshots retained the sequential filename format. - Added setting to specify a user directory for saving screenshots files. - Added edge padding instead of UV adjustment for background textures. - Now *"end"* picture is used for the final statistics background. - Added fade in/out between scenes. - Added TR1 styled transparent inventory background for hardware renderer (optional feature). This background is also used for level statistics like in the PlayStation version even if not set as inventory background. - Text box requester line height is slightly reduced to be more compact. - Added PlayStation styled inventory text box (optional feature). ### The original game bugfixes - Fixed the original game bug when the health bar is visible at the beginning of the final bath scene. - Screenshots now work properly in the windowed mode in modern Windows systems. - Screen tearing does not affect screenshots for the windowed mode anymore. - Fixed an issue where the final bath scene is cut off. Now it fades out like in the PlayStation version. - Text box frame is slightly adjusted to fill gaps in the corners. ### TR2Main bugfixes - Fixed incorrect underwater fog settings (broken since v0.4.0). - Fixed a minor issue related with clipping of round shadows (broken since v0.7.0). - Fixed clipping of animated background textures (broken since v0.3.0). ## [0.7.0] - 2018-07-28 ### New features - Added round shadows instead of octagonal (optional feature). ### The original game bugfixes - Fixed shadow clipping if the Z-Buffer is turned on. - Fixed a rare bug that caused black sprites to appear in bright rooms. ### TR2Main bugfixes - Fixed a bug that caused invisibility of pitch black sprites (broken since v0.4.0). ## [0.6.0] - 2018-02-24 ### New features - Custom HUD scaling options separated for the inventory and in-game (optional feature). ### The original game bugfixes - The size of the active screen area should always be 1.0 for credits and final statistics. ### TR2Main bugfixes - Health bar coordinates slightly corrected in the inventory for the PlayStation position style (broken since v0.5.0). ## [0.5.0] - 2018-02-17 ### New features - Improved optimization of the perspective correction for the software renderer (up to 2x faster than the original game code) - Text is unstretched for any display modes. - Added automatic scaling of text box borders depending on the current screen resolution. - Added automatic scaling of the assault course timer depending on the current screen resolution. - The best results of assault course are saved in the registry and are not reset after relaunching the game. - The health/air bar accuracy increased for higher resolutions. - Added PlayStation styled health bar position (optional feature). - Added custom HUD scaling options (optional feature). - Added simplified gradient health/air bars (optional feature; hardware renderer and Z-Buffer required). ### The original game bugfixes - Fixed texel adjustment if the renderer is changed by *Shift+F12* hotkey. - Fixed untextured polygon sorting for the software renderer. - Other minor bugfixes of the renderer. ### TR2Main bugfixes - Fixed cheat sequences (broken since v0.1.0). ## [0.4.0] - 2018-01-05 ### New features - Added draw distance and fog settings (optional feature). ### TR2Main bugfixes - Fixed texture minification filtering (broken since v0.1.0). - Fixed Z-Buffer for animated background of the inventory (broken since v0.3.0). - Fixed *"Select level"* option (broken since v0.1.0). ## [0.3.0] - 2018-01-03 ### New features - Added PlayStation styled field of view (optional feature). - Added PlayStation styled gradient health/air bars (optional feature; hardware renderer and Z-Buffer required). - Added PlayStation styled (animated) background of the inventory (optional feature; hardware renderer required). - Tiled static background of the inventory is unstretched for any display modes. ### The original game bugfixes - Fixed a rare game crash occurring when exiting the game while playing CD Audio. ### TR2Main bugfixes - Fixed back-face culling if the Z-Buffer is turned on (broken since v0.1.0). - Fixed a bug that prevented collecting more than one item of each type in the inventory (broken since v0.1.0). - Fixed a minor bug with looped tracks in the PaulD's CD Audio solution code (broken since v0.2.0). ## [0.2.0] - 2017-12-31 ### New features - The TGA screenshot captures the game window instead of the whole screen in the case of windowed mode. - Added PaulD's CD Audio solution. Now the game supports *cdaudio.mp3* / *cdaudio.dat* music package. Just put it into *audio* folder in the game installation directory. ### The original game bugfixes - Fixed default/custom keyboard layout conflicts when starting the game without visiting the controls menu. ### TR2Main bugfixes - Z-Buffer depth priority reverted to original 16/24/32/8 due to the *"CreateZBuffer"* errors on some systems (broken since v0.1.0). - Screenshot key is set to *BackSpace* (previously it was *PrintScreen*) to fix problems on some systems (broken since v0.1.0). - Fixed CD Audio synchronization bug (broken since v0.1.0). ## [0.1.0] - 2017-12-25 ### New features - Added NoCD patch. It is required that the *DATA* and *FMV* folders are located in the game installation folder, and not on the CD. - Added automatic adjustment of aspect ratio and field of view, depending on the current screen resolution. - Added automatic scaling of picked up items depending on the current screen resolution. - Added automatic scaling of secrets (dragons) in the level statistics menu depending on the current screen resolution. - Added automatic scaling of the health/air bars depending on the current screen resolution. - Video modes in the setup dialog are now sorted by depth, width and height. - Screenshot files are now created in the *screenshots* subfolder, not the game installation folder itself. - TGA screenshots are now available for 24/32-bit video modes. Not just for 16-bit video modes, as it was in the original game. - Screenshot key is set to *PrintScreen*. In the original game, it's set to the *S* key, which makes it unacceptable to map *S* key with another action. - ~~Z-Buffer depth priority set to 32/24/16/8 bits to improve rendering quality if a 32-bit Z-Buffer is available. In the original game, it is 16/24/32/8~~ (reverted in v0.2.0). ### The original game bugfixes - Fixed incorrect parameters of the game window, leading to the appearance of unwanted borders in full screen mode. - The default music volume level is set to 10/10. In the original game, the default value is 165/10, which leads to the absence of music until the volume level is adjusted in the game menu. - Fixed the *low ceiling jump* bug that was present in the early releases of the Tomb Raider II. In later versions, Core Design fixed it. - Fixed a bug that caused some graphic objects to disappear or flicker if the Z-Buffer is turned off. - Fixed a bug leading to a non-responsive keyboard when switching to another Windows application or launching a game using Wine under Linux. - Removed repeating actions caused by a single hotkey keystroke (F1, F2, F12, Screenshot key). One keystroke - one action! - Fixed the problem when the game overwrites the screenshot files made in previous launches of the game. - Fixed unsafe memory management in the screenshot function, which caused the game to crash at higher screen resolutions. - Fixed incorrect TGA screenshot creation. In the original game, the bottom line of pixels is filled with junk. [Unreleased]: https://github.com/Arsunt/TR2Main/compare/v0.9.0...HEAD [0.9.0]: https://github.com/Arsunt/TR2Main/compare/v0.8.2...v0.9.0 [0.8.2]: https://github.com/Arsunt/TR2Main/compare/v0.8.1...v0.8.2 [0.8.1]: https://github.com/Arsunt/TR2Main/compare/v0.8.0...v0.8.1 [0.8.0]: https://github.com/Arsunt/TR2Main/compare/v0.7.0...v0.8.0 [0.7.0]: https://github.com/Arsunt/TR2Main/compare/v0.6.0...v0.7.0 [0.6.0]: https://github.com/Arsunt/TR2Main/compare/v0.5.0...v0.6.0 [0.5.0]: https://github.com/Arsunt/TR2Main/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/Arsunt/TR2Main/compare/v0.3.0...v0.4.0 [0.3.0]: https://github.com/Arsunt/TR2Main/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/Arsunt/TR2Main/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/Arsunt/TR2Main/releases/tag/v0.1.0 ================================================ FILE: COPYING.md ================================================ GNU GENERAL PUBLIC LICENSE ========================== Version 3, 29 June 2007 ========================== > Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. # Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. # TERMS AND CONDITIONS ## 0. Definitions. _"This License"_ refers to version 3 of the GNU General Public License. _"Copyright"_ also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. _"The Program"_ refers to any copyrightable work licensed under this License. Each licensee is addressed as _"you"_. _"Licensees"_ and "recipients" may be individuals or organizations. To _"modify"_ a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a _"modified version"_ of the earlier work or a work _"based on"_ the earlier work. A _"covered work"_ means either the unmodified Program or a work based on the Program. To _"propagate"_ a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To _"convey"_ a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. ## 1. Source Code. The _"source code"_ for a work means the preferred form of the work for making modifications to it. _"Object code"_ means any non-source form of a work. A _"Standard Interface"_ means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The _"System Libraries"_ of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The _"Corresponding Source"_ for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. ## 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. ## 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. ## 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. ## 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. ## 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A _"User Product"_ is either (1) a _"consumer product"_, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. _"Installation Information"_ for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. ## 7. Additional Terms. _"Additional permissions"_ are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. ## 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. ## 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. ## 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An _"entity transaction"_ is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. ## 11. Patents. A _"contributor"_ is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's _"essential patent claims"_ are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. ## 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. ## 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. ## 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. ## 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. ## 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ## 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. # END OF TERMS AND CONDITIONS -------------------------------------------------------------------------- # How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands _'show w'_ and _'show c'_ should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: Doxyfile ================================================ # Doxyfile 1.8.13 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "TR2Main by Arsunt" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "Dynamic Linked Library implementing Tomb Raider 2 graphics" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = ./logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = ./doc # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: # Fortran. In the later case the parser tries to guess whether the code is fixed # or free formatted code, this is the default for Fortran type files), VHDL. For # instance to make doxygen treat .inc files as Fortran files (default is PHP), # and .f files as C (default is Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 0. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 0 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO, these declarations will be # included in the documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = YES # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. # The default value is: NO. WARN_AS_ERROR = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = ./src \ ./inc \ README.md \ COPYING.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.idl \ *.ddl \ *.odl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.cs \ *.d \ *.php \ *.php4 \ *.php5 \ *.phtml \ *.inc \ *.m \ *.markdown \ *.md \ *.mm \ *.dox \ *.py \ *.pyw \ *.f90 \ *.f95 \ *.f03 \ *.f08 \ *.f \ *.for \ *.tcl \ *.vhd \ *.vhdl \ *.ucf \ *.qsf # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the config file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse-libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /