⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qfiles.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
//100%
{$ALIGN ON}{$MINENUMSIZE 4}
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): qfiles.h - quake file formats                                     }
{                                                                            }
{ Initial conversion by : Lars Middendorf (lmid@gmx.de)                      }
{ Initial conversion on : 07-Jan-2002                                        }
{                                                                            }
{ This File contains part of convertion of Quake2 source to ObjectPascal.    }
{ More information about this project can be found at:                       }
{ http://www.sulaco.co.za/quake2/                                            }
{                                                                            }
{ Copyright (C) 1997-2001 Id Software, Inc.                                  }
{                                                                            }
{ 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 2             }
{ 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.                       }
{                                                                            }
{----------------------------------------------------------------------------}
{ * Updated:                                                                 }
{ 1) 12-Jan-2002 - Clootie (clootie@reactor.ru)                              }
{    Added pointer types and changed formatting to be more Borland like      }
{ 2) 18-Feb-2002 - Carl A Kenner (carl_kenner@hotmail.com)                   }
{    Made it work in Delphi 3                                                }
{ 3) 23-Feb-2002 - Carl A Kenner (carl_kenner@hotmail.com)                   }
{    Added array types                                                       }
{    Made it use q_shared so that I could use the right types                }
{ 4) 26-Feb-2002 - Carl A Kenner (carl_kenner@hotmail.com)                   }
{    Made types the right size                                               }
{                                                                            }
{----------------------------------------------------------------------------}
{ * Still dependent (to compile correctly) on:                               }
{ none                                                                       }
{----------------------------------------------------------------------------}
{ * TODO:                                                                    }
{ 1) 12-Jan-2002 - Clootie (clootie@reactor.ru) : Probably on some types     }
{    like "dtriangle_t" we should add pointer to array types:                }
{  dtriangle_at = array[0..MaxInt div SizeOf(dtriangle_t)-1] of dtriangle_t; }
{  dtriangle_a = ^dtriangle_at;                                              }
{----------------------------------------------------------------------------}

unit QFiles;


(*
========================================================================

The .pak files are just a linear collapse of a directory tree

========================================================================
*)

interface
uses q_shared;

const
 IDPAKHEADER = ((ord('K') shl 24)+(ord('C') shl 16)+(ord('A') shl 8)+ord('P'));

type
  dpackfile_p = ^dpackfile_t;
  pdpackfile_t = dpackfile_p;
  dpackfile_t = record
    name: array[0..55] of char;
    filepos, filelen: Integer;
  end;
  dpackfile_at = array[0..0] of dpackfile_t;
  dpackfile_a = ^dpackfile_at;

  dpackheader_p = ^dpackheader_t;
  pdpackheader_t = dpackheader_p;
  dpackheader_t = record
    ident: Integer;          // == IDPAKHEADER
    dirofs: Integer;
    dirlen: Integer;
  end;
  dpackheader_at = array[0..0] of dpackheader_t;
  dpackheader_a = ^dpackheader_at; 

const
 MAX_FILES_IN_PACK = 4096;

{
========================================================================

PCX files are used for as many images as possible

========================================================================
}
type
  pcx_p = ^pcx_t;
  ppcx_t = pcx_p;
  pcx_t = record
    manufacturer:       Char;
    version:            Char;
    encoding:           Char;
    bits_per_pixel:     Char;
    xmin, ymin, xmax, ymax: Word;
    hres, vres:         Word;
    palette:            array[0..47] of Byte;
    reserved:           Char;
    color_planes:       Byte;
    bytes_per_line:     Word;
    palette_type:       Word;
    filler:             array[0..57] of Char;
    data:               Byte;     // unbounded
  end;
  pcx_at = array[0..0] of pcx_t;
  pcx_a = ^pcx_at;

{
========================================================================

.MD2 triangle model file format

========================================================================
}

const
  IDALIASHEADER		= ((ord('2') shl 24)+(ord('P') shl 16)+(ord('D') shl 8)+ord('I'));
  ALIAS_VERSION   	= 8;

  MAX_TRIANGLES	        = 4096;
  MAX_VERTS		= 2048;
  MAX_FRAMES		= 512;
  MAX_MD2SKINS	        = 32;
  MAX_SKINNAME    	= 64;

type
  dstvert_p = ^dstvert_t;
  dstvert_t = record
    s: Smallint;
    t: Smallint;
  end;
  dstvert_at = array[0..0] of dstvert_t;
  dstvert_a = ^dstvert_at; 

  dtriangle_p = ^dtriangle_t;
  dtriangle_t = record
    index_xyz:  array[0..2] of Smallint;
    index_st:   array[0..2] of Smallint;
  end;
  dtriangle_at = array[0..0] of dtriangle_t;
  dtriangle_a = ^dtriangle_at;

  dtrivertx_p = ^dtrivertx_t;
  dtrivertx_t = record
    v: array[0..2] of Byte; // scaled byte to fit in frame mins/maxs
    lightnormalindex: Byte;
  end;
  dtrivertx_at = array[0..0] of dtrivertx_t;
  dtrivertx_a = ^dtrivertx_at;

const
  DTRIVERTX_V0          = 0;
  DTRIVERTX_V1          = 1;
  DTRIVERTX_V2          = 2;
  DTRIVERTX_LNI         = 3;
  DTRIVERTX_SIZE        = 4;

type
  daliasframe_p = ^daliasframe_t;
  daliasframe_t = record
    scale:      vec3_t;            // multiply byte verts by this
    translate:  vec3_t;        // then add this
    name:       array[0..15] of Char;              // frame name from grabbing
    verts:      array[0..0] of dtrivertx_t;       // variable sized
  end;
  daliasframe_at = array[0..0] of daliasframe_t;
  daliasframe_a = ^daliasframe_at;

// the glcmd format:
// a positive integer starts a tristrip command, followed by that many
// vertex structures.
// a negative integer starts a trifan command, followed by -x vertexes
// a zero indicates the end of the command list.
// a vertex consists of a floating point s, a floating point t,
// and an integer vertex index.


  dmdl_p = ^dmdl_t;
  dmdl_t = record
    ident:      Integer;
    version:    Integer;

    skinwidth:  Integer;
    skinheight: Integer;
    framesize:  Integer;        // byte size of each frame

    num_skins:  Integer;
    num_xyz:    Integer;
    num_st:     Integer;        // greater than num_xyz for seams
    num_tris:   Integer;
    num_glcmds: Integer;        // dwords in strip/fan command list
    num_frames: Integer;

    ofs_skins:  Integer;        // each skin is a MAX_SKINNAME string
    ofs_st:     Integer;        // byte offset from start for stverts
    ofs_tris:   Integer;        // offset for dtriangles
    ofs_frames: Integer;        // offset for first frame
    ofs_glcmds: Integer;
    ofs_end:    Integer;        // end of file
  end;
  dmdl_at = array[0..0] of dmdl_t;
  dmdl_a = ^dmdl_at;

{
========================================================================

.SP2 sprite file format

========================================================================
}

const
  IDSPRITEHEADER	= ((ord('2') shl 24)+(ord('S') shl 16)+(ord('D') shl 8)+ord('I'));
  // little-endian "IDS2"
  SPRITE_VERSION	= 2;


type
  dsprframe_p = ^dsprframe_t;
  dsprframe_t = record
   width, height:       Integer;
   origin_x, origin_y:  Integer;                     // raster coordinates inside pic
   name:                array[0..MAX_SKINNAME-1] of Char;
  end;
  dsprframe_at = array[0..0] of dsprframe_t;
  dsprframe_a = ^dsprframe_at;

  dsprite_p = ^dsprite_t;
  dsprite_t = record
    ident:      Integer;
    version:    Integer;
    numframes:  Integer;
    frames:     array[0..0] of dsprframe_t;  // variable sized
  end;
  dsprite_at = array[0..0] of dsprite_t;
  dsprite_a = ^dsprite_at;

{
==============================================================================

  .WAL texture file format

==============================================================================
}

const
  MIPLEVELS	        = 4;

type
  miptex_p = ^miptex_t;
  miptex_s = record
    name:               array[0..31] of Char;
    width, height:      Cardinal;
    offsets:            array[0..MIPLEVELS-1] of Cardinal; // four mip maps stored
    animname:           array[0..31] of Char;              // next frame in animation chain
    flags:              Integer;
    contents:           Integer;
    value:              Integer;
  end;
  miptex_t = miptex_s;
  miptex_at = array[0..0] of miptex_t;
  miptex_a = ^miptex_at;

{
==============================================================================

  .BSP file format

==============================================================================
}

const
  IDBSPHEADER	        = ((ord('P') shl 24)+(ord('S') shl 16)+(ord('B') shl 8)+ord('I'));
                          // little-endian "IBSP"
  BSPVERSION	        = 38;

  // upper design bounds
  // leaffaces, leafbrushes, planes, and verts are still bounded by
  // 16 bit short limits

  MAX_MAP_MODELS        = 1024;
  MAX_MAP_BRUSHES       = 8192;
  MAX_MAP_ENTITIES      = 2048;
  MAX_MAP_ENTSTRING     = $40000;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -