1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: i_system.h 1257 2016-09-20 17:14:21Z wesleyjohnson $
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 // Copyright (C) 1998-2016 by DooM Legacy Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 //
20 // $Log: i_system.h,v $
21 // Revision 1.8  2001/04/27 13:32:14  bpereira
22 // Revision 1.7  2001/02/24 13:35:20  bpereira
23 // Revision 1.6  2000/10/21 08:43:29  bpereira
24 // Revision 1.5  2000/10/02 18:25:45  bpereira
25 //
26 // Revision 1.4  2000/04/25 19:49:46  metzgermeister
27 // support for automatic wad search
28 //
29 // Revision 1.3  2000/04/16 18:38:07  bpereira
30 // Revision 1.2  2000/02/27 00:42:10  hurdler
31 // Revision 1.1.1.1  2000/02/22 20:32:32  hurdler
32 // Initial import into CVS (v1.29 pr3)
33 //
34 //
35 // DESCRIPTION:
36 //      System specific interface stuff.
37 //
38 //-----------------------------------------------------------------------------
39 
40 #ifndef I_SYSTEM_H
41 #define I_SYSTEM_H
42 
43 #include "doomtype.h"
44 #include "d_ticcmd.h"
45   // ticcmd_t
46 #include "d_event.h"
47 
48 // [WDJ] To inform and control graphics startup and shutdown.
49 typedef enum {
50    VGS_off,  // Unusable
51    // Some querys allowed, but not full graphics.
52    VGS_shutdown, // Mostly used to detect shutdown loops due to errors.
53    VGS_startup,
54    // Usable graphics for most of program.
55    VGS_active,  // have minimal graphics
56    VGS_fullactive  // have full graphics
57 } graphics_state_e;
58 extern byte graphics_state;  // graphics_state_e
59 
60 
61 // system initialization
62 void I_SysInit(void);
63 
64 // return free and total physical memory in the system
65 uint64_t I_GetFreeMem(uint64_t *total);
66 
67 // Called by D_DoomLoop,
68 // returns current time in tics.
69 tic_t I_GetTime (void);
70 
71 // replace getchar() once the keyboard has been appropriated
72 int I_GetKey (void);
73 
74 void I_GetEvent (void);
75 
76 
77 //
78 // Called by D_DoomLoop,
79 // called before processing any tics in a frame
80 // (just after displaying a frame).
81 // Time consuming syncronous operations
82 // are performed here (joystick reading).
83 // Can call D_PostEvent.
84 //
85 void I_StartFrame (void);
86 
87 
88 //
89 // Called by D_DoomLoop,
90 // called before processing each tic in a frame.
91 // Quick syncronous operations are performed here.
92 // Can call D_PostEvent.
93 void I_OsPolling (void);
94 
95 // Asynchronous interrupt functions should maintain private queues
96 // that are read by the synchronous functions
97 // to be converted into events.
98 
99 // Either returns a null ticcmd,
100 // or calls a loadable driver to build it.
101 // This ticcmd will then be modified by the gameloop
102 // for normal input.
103 ticcmd_t* I_BaseTiccmd (void);
104 
105 // sleeps for the given amount of milliseconds
106 void I_Sleep(unsigned int ms);
107 
108 // Called by M_Responder when quit is selected, return code 0.
109 typedef enum {
110    QUIT_normal,  // commanded quit
111    QUIT_shutdown,  // error quit
112    QUIT_panic    // I_Error or worse
113 } quit_severity_e;
114 // Quit without error (exit 0), no return, QUIT_normal.
115 void I_Quit (void);
116 // The system independent quit and save config.
117 void D_Quit_Save ( quit_severity_e severity );
118 // The final part of I_Quit, system dependent.
119 void I_Quit_System (void);
120 // Show the EndText, after the graphics are shutdown.
121 void I_Show_EndText( uint16_t * endtext );
122 
123 void I_Error (const char *error, ...);
124 
125 void I_Tactile (int on, int off, int total);
126 
127 //added:18-02-98: write a message to stderr (use before I_Quit)
128 //                for when you need to quit with a msg, but need
129 //                the return code 0 of I_Quit();
130 void I_OutputMsg (char *error, ...);
131 
132 #ifdef SMIF_WIN_NATIVE
133 void I_MsgBox (char * msg );
134 #endif
135 
136 /* list of functions to call at program cleanup */
137 void I_AddExitFunc (void (*func)(void));
138 void I_RemoveExitFunc (void (*func)(void));
139 
140 // Setup signal handler, plus stuff for trapping errors and cleanly exit.
141 // Not called by game, port optional, see I_SysInit
142 void I_StartupSystem (void);
143 // Not called by game, port optional, see I_Quit
144 void I_ShutdownSystem (void);
145 
146 uint64_t I_GetDiskFreeSpace(void);
147 char *I_GetUserName(void);
148 int  I_mkdir(const char *dirname, int unixright);
149 
150 // Get the directory of this program.
151 //   defdir: the default directory, if must use argv[0] method (may be NULL)
152 //   dirbuf: a buffer of length MAX_WADPATH,
153 // Return true when success, dirbuf contains the directory.
154 boolean I_Get_Prog_Dir( char * defdir, /*OUT*/ char * dirbuf );
155 
156 // Called on video mode change, usemouse change, mousemotion change,
157 // and game paused.
158 //   play_mode : enable mouse containment during play
159 void I_StartupMouse( boolean play_mode );
160 void I_StartupMouse2(void);
161 void I_UngrabMouse(void);
162 
163 // Shutdown joystick and other interfaces, before I_ShutdownGraphics.
164 void I_Shutdown_IO(void);
165 
166 #endif
167