home *** CD-ROM | disk | FTP | other *** search
/ Doom 2 Explosion / Doom2Explosion.bin / doom2exp / programs / deu521 / source / deu.h < prev    next >
C/C++ Source or Header  |  1994-05-22  |  13KB  |  409 lines

  1. /*
  2.    Doom Editor Utility, by Brendon Wyber and Raphaël Quinet.
  3.  
  4.    You are allowed to use any parts of this code in another program, as
  5.    long as you give credits to the authors in the documentation and in
  6.    the program itself.  Read the file README.1ST for more information.
  7.  
  8.    This program comes with absolutely no warranty.
  9.  
  10.    DEU.H - Main doom defines.
  11. */
  12.  
  13. /* the includes */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <stdarg.h>
  18. #include <ctype.h>
  19. #include <graphics.h>
  20. #include <alloc.h>
  21. #include <dos.h>
  22. #include <bios.h>
  23.  
  24.  
  25. /*
  26.    the version information
  27. */
  28.  
  29. #define DEU_VERSION    "5.21"    /* the version number */
  30.  
  31.  
  32.  
  33. /*
  34.    the directory structure is the structre used by DOOM to order the
  35.    data in it's WAD files
  36. */
  37.  
  38. typedef struct Directory huge *DirPtr;
  39. struct Directory
  40. {
  41.    long start;            /* offset to start of data */
  42.    long size;            /* byte size of data */
  43.    char name[ 8];        /* name of data block */
  44. };
  45.  
  46.  
  47.  
  48. /*
  49.    The wad file pointer structure is used for holding the information
  50.    on the wad files in a linked list.
  51.  
  52.    The first wad file is the main wad file. The rest are patches.
  53. */
  54.  
  55. typedef struct WadFileInfo huge *WadPtr;
  56. struct WadFileInfo
  57. {
  58.    WadPtr next;            /* next file in linked list */
  59.    char *filename;        /* name of the wad file */
  60.    FILE *fileinfo;        /* C file stream information */
  61.    char type[ 4];        /* type of wad file (IWAD or PWAD) */
  62.    long dirsize;        /* directory size of WAD */
  63.    long dirstart;        /* offset to start of directory */
  64.    DirPtr directory;        /* array of directory information */
  65. };
  66.  
  67.  
  68.  
  69. /*
  70.    the master directory structure is used to build a complete directory
  71.    of all the data blocks from all the various wad files
  72. */
  73.  
  74. typedef struct MasterDirectory huge *MDirPtr;
  75. struct MasterDirectory
  76. {
  77.    MDirPtr next;        /* next in list */
  78.    WadPtr wadfile;        /* file of origin */
  79.    struct Directory dir;    /* directory data */
  80. };
  81.  
  82.  
  83.  
  84. /*
  85.    the selection list is used when more than one object is selected
  86. */
  87.  
  88. typedef struct SelectionList *SelPtr;
  89. struct SelectionList
  90. {
  91.    SelPtr next;            /* next in list */
  92.    int objnum;            /* object number */
  93. };
  94.  
  95.  
  96. /*
  97.    syntactic sugar
  98. */
  99. typedef int Bool;               /* Boolean data: true or false */
  100.  
  101.  
  102. /*
  103.    description of the command line arguments and config file keywords
  104. */
  105.  
  106. typedef struct
  107. {
  108.    char *short_name;        /* abbreviated command line argument */
  109.    char *long_name;        /* command line arg. or keyword */
  110.    enum                /* type of this option */
  111.    {
  112.       OPT_BOOLEAN,            /* boolean (toggle) */
  113.       OPT_INTEGER,            /* integer number */
  114.       OPT_STRING,            /* character string */
  115.       OPT_STRINGACC,            /* character string, but store in a list */
  116.       OPT_STRINGLIST,            /* list of character strings */
  117.       OPT_END                /* end of the options description */
  118.    } opt_type;
  119.    char *msg_if_true;        /* message printed if option is true */
  120.    char *msg_if_false;        /* message printed if option is false */
  121.    void *data_ptr;              /* pointer to the data */
  122. } OptDesc;
  123.  
  124.  
  125. /*
  126.    the macros and constants
  127. */
  128.  
  129. /* name of the configuration file */
  130. #define DEU_CONFIG_FILE        "DEU.INI"
  131.  
  132. /* name of the log file (debug mode) */
  133. #define DEU_LOG_FILE        "DEU.LOG"
  134.  
  135. /* convert screen coordinates to map coordinates */
  136. #define MAPX(x)            (OrigX + (int) (((x) - ScrCenterX) / Scale))
  137. #define MAPY(y)            (OrigY + (int) ((ScrCenterY - (y)) / Scale))
  138.  
  139. /* convert map coordinates to screen coordinates */
  140. #define SCREENX(x)        (ScrCenterX + (int) (((x) - OrigX) * Scale))
  141. #define SCREENY(y)        (ScrCenterY + (int) ((OrigY - (y)) * Scale))
  142.  
  143. /* object types */
  144. #define OBJ_THINGS        1
  145. #define OBJ_LINEDEFS        2
  146. #define OBJ_SIDEDEFS        3
  147. #define OBJ_VERTEXES        4
  148. #define OBJ_SEGS        5
  149. #define OBJ_SSECTORS        6
  150. #define OBJ_NODES        7
  151. #define OBJ_SECTORS        8
  152. #define OBJ_REJECT        9
  153. #define OBJ_BLOCKMAP        10
  154.  
  155. /* boolean constants */
  156. #define TRUE            1
  157. #define FALSE            0
  158.  
  159. /* half the size of an object (Thing or Vertex) in map coords */
  160. #define OBJSIZE            7
  161.  
  162.  
  163. /*
  164.    the interfile global variables
  165. */
  166.  
  167. /* from deu.c */
  168. extern Bool  Registered;    /* registered or shareware WAD file? */
  169. extern Bool  Debug;        /* are we debugging? */
  170. extern Bool  SwapButtons;    /* swap right and middle mouse buttons */
  171. extern Bool  Quiet;        /* don't play a sound when an object is selected */
  172. extern Bool  Quieter;        /* don't play any sound, even when an error occurs */
  173. extern Bool  Expert;        /* don't ask for confirmation for some operations */
  174. extern int   InitialScale;    /* initial zoom factor for map */
  175. extern int   VideoMode;        /* default video mode for VESA cards */
  176. extern char *BGIDriver;        /* default extended BGI driver */
  177. extern Bool  FakeCursor;    /* use a "fake" mouse cursor */
  178. extern Bool  CirrusCursor;    /* use hardware cursor on Cirrus Logic VGA cards */
  179. extern Bool  Colour2;        /* use the alternate set for things colors */
  180. extern Bool  AdditiveSelBox;    /* additive selection box or select in box only? */
  181. extern int   SplitFactor;    /* factor used by the Nodes builder */
  182. extern Bool  Select0;        /* select object 0 by default when switching modes */
  183. extern char *MainWad;        /* name of the main wad file */
  184. extern FILE *logfile;        /* filepointer to the error log */
  185.  
  186. /* from wads.c */
  187. extern WadPtr  WadFileList;    /* list of wad files */
  188. extern MDirPtr MasterDir;    /* the master directory */
  189.  
  190. /* from edit.c */
  191. extern Bool InfoShown;          /* is the bottom line displayed? */
  192.  
  193. /* from gfx.c */
  194. extern int   GfxMode;        /* current graphics mode, or 0 for text */
  195. extern float Scale;        /* scale to draw map 20 to 1 */
  196. extern int   OrigX;        /* the X origin */
  197. extern int   OrigY;        /* the Y origin */
  198. extern int   PointerX;        /* X position of pointer */
  199. extern int   PointerY;        /* Y position of pointer */
  200. extern int   ScrMaxX;        /* maximum X screen coord */
  201. extern int   ScrMaxY;        /* maximum Y screen coord */
  202. extern int   ScrCenterX;    /* X coord of screen center */
  203. extern int   ScrCenterY;    /* Y coord of screen center */
  204.  
  205. /* from mouse.c */
  206. extern Bool UseMouse;        /* is there a mouse driver? */
  207.  
  208.  
  209.  
  210. /*
  211.    the function prototypes
  212. */
  213.  
  214. /* from deu.c */
  215. int main( int, char *[]);
  216. void ParseCommandLineOptions( int, char *[]);
  217. void ParseConfigFileOptions( char *);
  218. void Usage( FILE *);
  219. void Credits( FILE *);
  220. void FunnyMessage( FILE *);
  221. void Beep( void);
  222. void PlaySound( int, int);
  223. void ProgError( char *, ...);
  224. void LogMessage( char *, ...);
  225. void MainLoop( void);
  226.  
  227. /* from memory.c */
  228. void *GetMemory( size_t);
  229. void *ResizeMemory( void *, size_t);
  230. void FreeMemory( void *);
  231. void huge *GetFarMemory( unsigned long size);
  232. void huge *ResizeFarMemory( void huge *old, unsigned long size);
  233. void FreeFarMemory( void huge *);
  234.  
  235. /* from wads.c */
  236. void OpenMainWad( char *);
  237. void OpenPatchWad( char *);
  238. void CloseWadFiles( void);
  239. void CloseUnusedWadFiles( void);
  240. WadPtr BasicWadOpen( char *);
  241. void BasicWadRead( WadPtr, void huge *, long);
  242. void BasicWadSeek( WadPtr, long);
  243. MDirPtr FindMasterDir( MDirPtr, char *);
  244. void ListMasterDirectory( FILE *);
  245. void ListFileDirectory( FILE *, WadPtr);
  246. void BuildNewMainWad( char *, Bool);
  247. void WriteBytes( FILE *, void huge *, long);
  248. void CopyBytes( FILE *, FILE *, long);
  249. int Exists( char *);
  250. void DumpDirectoryEntry( FILE *, char *);
  251. void SaveDirectoryEntry( FILE *, char *);
  252. void SaveEntryToRawFile( FILE *, char *);
  253. void SaveEntryFromRawFile( FILE *, FILE *, char *);
  254.  
  255. /* from levels.c */
  256. void ReadLevelData( int, int); /* SWAP! */
  257. void ForgetLevelData( void); /* SWAP! */
  258. void SaveLevelData( char *); /* SWAP! */
  259. void ReadWTextureNames( void);
  260. void ForgetFTextureNames( void);
  261. void ReadFTextureNames( void);
  262. void ForgetWTextureNames( void);
  263.  
  264. /* from edit.c */
  265. void EditLevel( int, int, Bool);
  266. void SelectLevel( int *, int *);
  267. void EditorLoop( int, int); /* SWAP! */
  268. void DrawMap( int, int, Bool); /* SWAP! */
  269. void CenterMapAroundCoords( int, int);
  270. void GoToObject( int, int); /* SWAP! */
  271.  
  272. /* from gfx.c */
  273. void InitGfx( void);
  274. Bool SwitchToVGA256( void);
  275. Bool SwitchToVGA16( void);
  276. void TermGfx( void);
  277. void ClearScreen( void);
  278. void SetColor( int);
  279. void DrawMapLine( int, int, int, int);
  280. void DrawMapCircle( int, int, int);
  281. void DrawMapVector( int, int, int, int);
  282. void DrawMapArrow( int, int, unsigned);
  283. void DrawScreenLine( int, int, int, int);
  284. void DrawScreenBox( int, int, int, int);
  285. void DrawScreenBox3D( int, int, int, int);
  286. void DrawScreenBoxHollow( int, int, int, int);
  287. void DrawScreenMeter( int, int, int, int, float);
  288. void DrawScreenText( int, int, char *, ...);
  289. void DrawPointer( Bool);
  290. void SetDoomPalette( int);
  291. int TranslateToDoomColor( int);
  292. unsigned ComputeAngle( int, int);
  293. unsigned ComputeDist( int, int);
  294. void InsertPolygonVertices( int, int, int, int);
  295. void RotateAndScaleCoords( int *, int *, double, double);
  296. #ifdef CIRRUS_PATCH
  297. void SetHWCursorPos( unsigned, unsigned);
  298. void SetHWCursorCol( long, long);
  299. void SetHWCursorMap( char *);
  300. #endif /* CIRRUS_PATCH */
  301.  
  302. /* from things.c */
  303. int GetThingColour( int);
  304. char *GetThingName( int);
  305. int GetThingRadius( int);
  306. char *GetAngleName( int);
  307. char *GetWhenName( int);
  308.  
  309. /* from names.c */
  310. char *GetObjectTypeName( int);
  311. char *GetEditModeName( int);
  312. char *GetLineDefTypeName( int);
  313. char *GetLineDefTypeLongName( int);
  314. char *GetLineDefFlagsName( int);
  315. char *GetLineDefFlagsLongName( int);
  316. char *GetSectorTypeName( int);
  317. char *GetSectorTypeLongName( int);
  318.  
  319. /* from mouse.c */
  320. void CheckMouseDriver( void);
  321. void ShowMousePointer( void);
  322. void HideMousePointer( void);
  323. void GetMouseCoords( int *, int *, int *);
  324. void SetMouseCoords( int, int);
  325. void SetMouseLimits( int, int, int, int);
  326. void ResetMouseLimits( void);
  327. void MouseCallBackFunction( void);
  328.  
  329. /* from menus.c */
  330. int DisplayMenuArray( int, int, char *, int, int *, char *[ 30], int [30]);
  331. int DisplayMenu( int, int, char *, ...);
  332. int PullDownMenu( int, int, ...);
  333. int InputInteger( int, int, int *, int, int);
  334. int InputIntegerValue( int, int, int, int, int);
  335. void InputNameFromListWithFunc( int, int, char *, int, char **, int, char *, int, int, void (*hookfunc)(int, int, int, int, char *));
  336. void InputNameFromList( int, int, char *, int, char **, char *);
  337. void InputFileName( int, int, char *, int, char *);
  338. Bool Confirm( int, int, char *, char *);
  339. void Notify( int, int, char *, char *);
  340. void DisplayMessage( int, int, char *, ...);
  341. void NotImplemented( void);
  342.  
  343. /* from objects.c */
  344. void HighlightSelection( int, SelPtr); /* SWAP! */
  345. Bool IsSelected( SelPtr, int);
  346. void SelectObject( SelPtr *, int);
  347. void UnSelectObject( SelPtr *, int);
  348. void ForgetSelection( SelPtr *);
  349. int GetMaxObjectNum( int);
  350. int GetCurObject( int, int, int, int, int); /* SWAP! */
  351. SelPtr SelectObjectsInBox( int, int, int, int, int); /* SWAP! */
  352. void HighlightObject( int, int, int); /* SWAP! */
  353. void DeleteObject( int, int); /* SWAP! */
  354. void DeleteObjects( int, SelPtr *); /* SWAP! */
  355. void InsertObject( int, int, int, int); /* SWAP! */
  356. Bool IsLineDefInside( int, int, int, int, int); /* SWAP - needs Vertexes & LineDefs */
  357. int GetOppositeSector( int, Bool); /* SWAP! */
  358. void CopyObjects( int, SelPtr); /* SWAP! */
  359. Bool MoveObjectsToCoords( int, SelPtr, int, int, int); /* SWAP! */
  360. void GetObjectCoords( int, int, int *, int *); /* SWAP! */
  361. void RotateAndScaleObjects( int, SelPtr, double, double); /* SWAP! */
  362. int FindFreeTag( void); /* SWAP! */
  363. void FlipLineDefs( SelPtr, Bool); /* SWAP! */
  364. void DeleteVerticesJoinLineDefs( SelPtr ); /* SWAP! */
  365. void MergeVertices( SelPtr *); /* SWAP! */
  366. Bool AutoMergeVertices( SelPtr *); /* SWAP! */
  367. void SplitLineDefs( SelPtr); /* SWAP! */
  368. void SplitSector( int, int); /* SWAP! */
  369. void SplitLineDefsAndSector( int, int); /* SWAP! */
  370. void MergeSectors( SelPtr *); /* SWAP! */
  371. void DeleteLineDefsJoinSectors( SelPtr *); /* SWAP! */
  372. void MakeDoorFromSector( int); /* SWAP! */
  373. void MakeLiftFromSector( int); /* SWAP! */
  374. void AlignTexturesY( SelPtr *); /* SWAP! */
  375. void AlignTexturesX( SelPtr *); /* SWAP! */
  376. void DistributeSectorFloors( SelPtr); /* SWAP! */
  377. void DistributeSectorCeilings( SelPtr); /* SWAP! */
  378.  
  379. /* from editobj.c */
  380. void DisplayObjectInfo( int, int); /* SWAP! */
  381. int DisplayThingsMenu( int, int, char *, ...);
  382. int DisplayLineDefTypeMenu( int, int, char *, ...);
  383. int InputObjectNumber( int, int, int, int);
  384. int InputObjectXRef( int, int, int, Bool, int);
  385. Bool Input2VertexNumbers( int, int, char *, int *, int *);
  386. void EditObjectsInfo( int, int, int, SelPtr);
  387. void CheckLevel( int, int); /* SWAP! */
  388. Bool CheckStartingPos( void); /* SWAP! */
  389. void InsertStandardObject( int, int, int, int); /* SWAP! */
  390. void MiscOperations( int, int, int, SelPtr *); /* SWAP! */
  391. void Preferences( int, int);
  392.  
  393. /* from nodes.c */
  394. void ShowProgress( int);
  395.  
  396. /* from textures.c */
  397. void ChooseFloorTexture( int, int, char *, int, char **, char *);
  398. void ChooseWallTexture( int, int, char *, int, char **, char *);
  399. void ChooseSprite( int, int, char *, char *);
  400. void GetWallTextureSize( int *, int *, char *);
  401.  
  402. /* from swapmem.c */
  403. void InitSwap( void);
  404. void FreeSomeMemory( void);
  405. void ObjectsNeeded( int, ...);
  406.  
  407.  
  408. /* end of file */
  409.