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