home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / GAMES_C / DEU50.ZIP / SOURCE.ZIP / DEU.H < prev    next >
C/C++ Source or Header  |  1994-03-30  |  11KB  |  351 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.  
  22.  
  23.  
  24. /*
  25.    the version information
  26. */
  27.  
  28. #define DEU_VERSION    "5.00"    /* the version number */
  29.  
  30.  
  31.  
  32. /*
  33.    the directory structure is the structre used by DOOM to order the
  34.    data in it's WAD files
  35. */
  36.  
  37. typedef struct Directory huge *DirPtr;
  38. struct Directory
  39. {
  40.    long start;            /* offset to start of data */
  41.    long size;            /* byte size of data */
  42.    char name[ 8];        /* name of data block */
  43. };
  44.  
  45.  
  46.  
  47. /*
  48.    The wad file pointer structure is used for holding the information
  49.    on the wad files in a linked list.
  50.  
  51.    The first wad file is the main wad file. The rest are patches.
  52. */
  53.  
  54. typedef struct WadFileInfo huge *WadPtr;
  55. struct WadFileInfo
  56. {
  57.    WadPtr next;            /* next file in linked list */
  58.    char *filename;        /* name of the wad file */
  59.    FILE *fileinfo;        /* C file stream information */
  60.    char type[ 4];        /* type of wad file (IWAD or PWAD) */
  61.    long dirsize;        /* directory size of WAD */
  62.    long dirstart;        /* offset to start of directory */
  63.    DirPtr directory;        /* array of directory information */
  64. };
  65.  
  66.  
  67.  
  68. /*
  69.    the master directory structure is used to build a complete directory
  70.    of all the data blocks from all the various wad files
  71. */
  72.  
  73. typedef struct MasterDirectory huge *MDirPtr;
  74. struct MasterDirectory
  75. {
  76.    MDirPtr next;        /* next in list */
  77.    WadPtr wadfile;        /* file of origin */
  78.    struct Directory dir;    /* directory data */
  79. };
  80.  
  81.  
  82.  
  83. /*
  84.    the selection list is used when more than one object is selected
  85. */
  86.  
  87. typedef struct SelectionList *SelPtr;
  88. struct SelectionList
  89. {
  90.    SelPtr next;            /* next in list */
  91.    int objnum;            /* object number */
  92. };
  93.  
  94.  
  95. /*
  96.    syntactic sugar
  97. */
  98. typedef int Bool;               /* Boolean data: true or false */
  99.  
  100.  
  101. /*
  102.    description of the command line arguments and config file keywords
  103. */
  104.  
  105. typedef struct
  106. {
  107.    char *short_name;        /* abbreviated command line argument */
  108.    char *long_name;        /* command line arg. or keyword */
  109.    enum                /* type of this option */
  110.    {
  111.       OPT_BOOLEAN,            /* boolean (toggle) */
  112.       OPT_INTEGER,            /* integer number */
  113.       OPT_STRING,            /* character string */
  114.       OPT_STRINGACC,            /* character string, but store in a list */
  115.       OPT_STRINGLIST,            /* list of character strings */
  116.       OPT_NONE                /* end of the options description */
  117.    } opt_type;
  118.    char *msg_if_true;        /* message printed if option is true */
  119.    char *msg_if_false;        /* message printed if option is false */
  120.    void *data_ptr;              /* pointer to the data */
  121. } OptDesc;
  122.  
  123.  
  124. /*
  125.    the macros and constants
  126. */
  127.  
  128. /* name of the configuration file */
  129. #define DEU_CONFIG_FILE        "DEU.INI"
  130.  
  131. /* convert pointer coordinates to map coordinates */
  132. #define MAPX(x)            (OrigX + (x - ScrCenterX) * Scale)
  133. #define MAPY(y)            (OrigY + (ScrCenterY - y) * Scale)
  134.  
  135. /* object types */
  136. #define OBJ_THINGS        1
  137. #define OBJ_LINEDEFS        2
  138. #define OBJ_SIDEDEFS        3
  139. #define OBJ_VERTEXES        4
  140. #define OBJ_SEGS        5
  141. #define OBJ_SSECTORS        6
  142. #define OBJ_NODES        7
  143. #define OBJ_SECTORS        8
  144. #define OBJ_REJECT        9
  145. #define OBJ_BLOCKMAP        10
  146.  
  147. /* boolean constants */
  148. #define TRUE            1
  149. #define FALSE            0
  150.  
  151. /* half the size of an object (Thing or Vertex) in map coords */
  152. #define OBJSIZE            15
  153.  
  154.  
  155. /*
  156.    the interfile global variables
  157. */
  158.  
  159. /* from deu.c */
  160. extern Bool  Registered;    /* registered or shareware WAD file? */
  161. extern Bool  Debug;        /* are we debugging? */
  162. extern Bool  SwapButtons;    /* swap right and middle mouse buttons */
  163. extern Bool  Quiet;        /* don't play a sound when an object is selected */
  164. extern Bool  Expert;        /* don't ask for confirmation for some operations */
  165. extern int   InitialScale;    /* initial zoom factor for map */
  166. extern int   VideoMode;        /* default video mode for VESA cards */
  167. extern char *BGIDriver;        /* default extended BGI driver */
  168. extern Bool  FakeCursor;    /* use a "fake" mouse cursor */
  169. extern Bool  Colour2;        /* use the alternate set for things colors */
  170. extern char *MainWad;        /* name of the main wad file */
  171.  
  172. /* from wads.c */
  173. extern WadPtr  WadFileList;    /* list of wad files */
  174. extern MDirPtr MasterDir;    /* the master directory */
  175.  
  176. /* from levels.c */
  177. extern int    NumWTexture;    /* number of wall textures */
  178. extern char **WTexture;        /* wall texture names */
  179. extern int    NumFTexture;    /* number of floor/ceiling textures */
  180. extern char **FTexture;        /* floor/ceiling texture names */
  181.  
  182. /* from edit.c */
  183. extern Bool InfoShown;          /* is the bottom line displayed? */
  184.  
  185. /* from gfx.c */
  186. extern int GfxMode;        /* current graphics mode, or 0 for text */
  187. extern int Scale;        /* scale to draw map 20 to 1 */
  188. extern int OrigX;        /* the X origin */
  189. extern int OrigY;        /* the Y origin */
  190. extern int PointerX;        /* X position of pointer */
  191. extern int PointerY;        /* Y position of pointer */
  192. extern int ScrMaxX;        /* maximum X screen coord */
  193. extern int ScrMaxY;        /* maximum Y screen coord */
  194. extern int ScrCenterX;        /* X coord of screen center */
  195. extern int ScrCenterY;        /* Y coord of screen center */
  196.  
  197. /* from mouse.c */
  198. extern Bool UseMouse;        /* is there a mouse driver? */
  199.  
  200.  
  201.  
  202. /*
  203.    the function prototypes
  204. */
  205.  
  206. /* from deu.c */
  207. int main( int, char *[]);
  208. void ParseCommandLineOptions( int, char *[]);
  209. void ParseConfigFileOptions( char *);
  210. void Usage( FILE *);
  211. void Credits( FILE *);
  212. void Beep( void);
  213. void ProgError( char *, ...);
  214. void *GetMemory( size_t);
  215. void *ResizeMemory( void *, size_t);
  216. void huge *GetFarMemory( unsigned long size);
  217. void huge *ResizeFarMemory( void huge *old, unsigned long size);
  218. void MainLoop( void);
  219.  
  220. /* from wads.c */
  221. void OpenMainWad( char *);
  222. void OpenPatchWad( char *);
  223. void CloseWadFiles( void);
  224. void CloseUnusedWadFiles( void);
  225. WadPtr BasicWadOpen( char *);
  226. void BasicWadRead( WadPtr, void huge *, long);
  227. void BasicWadSeek( WadPtr, long);
  228. MDirPtr FindMasterDir( MDirPtr, char *);
  229. void ListMasterDirectory( FILE *);
  230. void ListFileDirectory( FILE *, WadPtr);
  231. void BuildNewMainWad( char *, Bool);
  232. void WriteBytes( FILE *, void huge *, long);
  233. int Exists( char *);
  234. void DumpDirectoryEntry( FILE *, char *);
  235. void SaveDirectoryEntry( FILE *, char *);
  236.  
  237. /* from levels.c */
  238. void ReadLevelData( int, int);
  239. void ForgetLevelData( void);
  240. void SaveLevelData( char *);
  241. void ReadWTextureNames( void);
  242. void ForgetFTextureNames( void);
  243. void ReadFTextureNames( void);
  244. void ForgetWTextureNames( void);
  245.  
  246. /* from edit.c */
  247. void EditLevel( int, int, Bool);
  248. void SelectLevel( int *, int *);
  249. void EditorLoop( int, int);
  250. void DrawMap( int, int);
  251.  
  252. /* from gfx.c */
  253. void InitGfx( void);
  254. Bool SwitchToVGA256( void);
  255. Bool SwitchToVGA16( void);
  256. void TermGfx( void);
  257. void ClearScreen( void);
  258. void SetColor( int);
  259. void DrawMapLine( int, int, int, int);
  260. void DrawMapCircle( int, int, int);
  261. void DrawMapVector( int, int, int, int);
  262. void DrawMapArrow( int, int, unsigned);
  263. void DrawScreenLine( int, int, int, int);
  264. void DrawScreenBox( int, int, int, int);
  265. void DrawScreenBox3D( int, int, int, int);
  266. void DrawScreenBoxHollow( int, int, int, int);
  267. void DrawScreenMeter( int, int, int, int, float);
  268. void DrawScreenText( int, int, char *, ...);
  269. void DrawPointer( void);
  270. void SetDoomPalette( int);
  271. int TranslateToDoomColor( int);
  272. unsigned ComputeAngle( int, int);
  273. unsigned ComputeDist( int, int);
  274. void InsertPolygonVertices( int, int, int, int);
  275.  
  276. /* from things.c */
  277. int GetThingColour( int);
  278. char *GetThingName( int);
  279. int GetThingRadius( int);
  280. char *GetAngleName( int);
  281. char *GetWhenName( int);
  282.  
  283. /* from names.c */
  284. char *GetObjectTypeName( int);
  285. char *GetEditModeName( int);
  286. char *GetLineDefTypeName( int);
  287. char *GetLineDefTypeLongName( int);
  288. char *GetLineDefFlagsName( int);
  289. char *GetLineDefFlagsLongName( int);
  290. char *GetSectorTypeName( int);
  291. char *GetSectorTypeLongName( int);
  292.  
  293. /* from mouse.c */
  294. void CheckMouseDriver( void);
  295. void ShowMousePointer( void);
  296. void HideMousePointer( void);
  297. void GetMouseCoords( int *, int *, int *);
  298. void SetMouseCoords( int, int);
  299. void SetMouseLimits( int, int, int, int);
  300. void ResetMouseLimits( void);
  301.  
  302. /* from menus.c */
  303. int DisplayMenuArray( int, int, char *, int, int *, char *[ 30]);
  304. int DisplayMenu( int, int, char *, ...);
  305. int PullDownMenu( int, int, ...);
  306. int InputInteger( int, int, int *, int, int);
  307. int InputIntegerValue( int, int, int, int, int);
  308. void InputNameFromListWithFunc( int, int, char *, int, char **, int, char *, int, int, void (*hookfunc)(int, int, char *));
  309. void InputNameFromList( int, int, char *, int, char **, char *);
  310. void InputFileName( int, int, char *, int, char *);
  311. Bool Confirm( int, int, char *, char *);
  312. void Notify( int, int, char *, char *);
  313. void DisplayMessage( int, int, char *, ...);
  314. void NotImplemented( void);
  315.  
  316. /* from objects.c */
  317. void HighlightSelection( int, SelPtr);
  318. Bool IsSelected( SelPtr, int);
  319. void SelectObject( SelPtr *, int);
  320. void UnSelectObject( SelPtr *, int);
  321. void ForgetSelection( SelPtr *);
  322. int GetCurObject( int, int, int, int, int);
  323. SelPtr SelectObjectsInBox( int, int, int, int, int);
  324. void HighlightObject( int, int, int);
  325. void DeleteObject( int, int);
  326. void DeleteObjects( int, SelPtr *);
  327. void InsertObject( int, int, int, int);
  328. Bool IsLineDefInside( int, int, int, int, int);
  329.  
  330. /* from editobj.c */
  331. void DisplayObjectInfo( int, int);
  332. int DisplayThingsMenu( int, int, char *, ...);
  333. int DisplayLineDefTypeMenu( int, int, char *, ...);
  334. int InputObjectNumber( int, int, int, int);
  335. int InputObjectXRef( int, int, int, Bool, int);
  336. int Input2VertexNumber( int, int, char *, int *, int *);
  337. void EditObjectsInfo( int, int, int, SelPtr);
  338. Bool MoveObjectsToCoords( int, SelPtr, int, int, int);
  339. void InsertStandardObject( int, int, int, int);
  340. void MiscOperations( int, int, int, SelPtr);
  341.  
  342. /* from nodes.c */
  343. void ShowProgress( int);
  344.  
  345. /* from textures.c */
  346. void ChooseFloorTexture( int, int, char *, int, char **, char *);
  347. void ChooseWallTexture( int, int, char *, int, char **, char *);
  348. void ChooseSprite( int, int, char *, char *);
  349.  
  350. /* end of file */
  351.