1 #ifndef CONSOLE_H |
1 #ifndef CONSOLE_H |
2 #define CONSOLE_H |
2 #define CONSOLE_H |
3 |
3 |
4 // ** console ** // |
|
5 |
|
6 enum { |
|
7 ICONSOLE_OPENED=0, |
|
8 ICONSOLE_CLOSED, |
|
9 } _iconsole_modes; |
|
10 |
|
11 // ** console parser ** // |
4 // ** console parser ** // |
12 |
5 |
13 enum { |
6 typedef enum _iconsole_var_types { |
14 ICONSOLE_VAR_NONE=0, |
7 ICONSOLE_VAR_NONE, |
15 ICONSOLE_VAR_BOOLEAN, |
8 ICONSOLE_VAR_BOOLEAN, |
16 ICONSOLE_VAR_BYTE, |
9 ICONSOLE_VAR_BYTE, |
17 ICONSOLE_VAR_UINT16, |
10 ICONSOLE_VAR_UINT16, |
18 ICONSOLE_VAR_UINT32, |
11 ICONSOLE_VAR_UINT32, |
19 ICONSOLE_VAR_INT16, |
12 ICONSOLE_VAR_INT16, |
20 ICONSOLE_VAR_INT32, |
13 ICONSOLE_VAR_INT32, |
21 ICONSOLE_VAR_STRING, |
14 ICONSOLE_VAR_STRING, |
22 ICONSOLE_VAR_POINTER, |
15 ICONSOLE_VAR_POINTER, |
23 ICONSOLE_VAR_REFERENCE, |
16 ICONSOLE_VAR_REFERENCE, |
24 ICONSOLE_VAR_UNKNOWN, |
17 ICONSOLE_VAR_UNKNOWN |
25 } _iconsole_var_types; |
18 } _iconsole_var_types; |
26 |
19 |
27 enum { |
20 typedef enum _iconsole_hook_types { |
28 ICONSOLE_HOOK_ACCESS, |
21 ICONSOLE_HOOK_ACCESS, |
29 ICONSOLE_HOOK_BEFORE_CHANGE, |
22 ICONSOLE_HOOK_BEFORE_CHANGE, |
30 ICONSOLE_HOOK_BEFORE_EXEC, |
23 ICONSOLE_HOOK_BEFORE_EXEC, |
31 ICONSOLE_HOOK_AFTER_CHANGE, |
24 ICONSOLE_HOOK_AFTER_CHANGE, |
32 ICONSOLE_HOOK_AFTER_EXEC, |
25 ICONSOLE_HOOK_AFTER_EXEC |
33 } _iconsole_hook_types; |
26 } _iconsole_hook_types; |
34 |
27 |
35 typedef struct { |
28 struct _iconsole_var; |
|
29 typedef bool (*iconsole_var_hook)(struct _iconsole_var* hook_var); |
|
30 |
|
31 typedef struct _iconsole_var { |
|
32 // --------------- // |
|
33 union { |
|
34 void* addr; |
|
35 bool* bool_; |
|
36 byte* byte_; |
|
37 uint16* uint16_; |
|
38 uint32* uint32_; |
|
39 int16* int16_; |
|
40 int32* int32_; |
|
41 char* string_; |
|
42 struct _iconsole_var* reference_; |
|
43 } data; |
|
44 char* name; |
|
45 _iconsole_var_types type; |
36 // -------------- // |
46 // -------------- // |
37 void * addr; |
47 iconsole_var_hook hook_access; |
38 byte * name; |
48 iconsole_var_hook hook_before_change; |
|
49 iconsole_var_hook hook_after_change; |
39 // -------------- // |
50 // -------------- // |
40 void * hook_access; |
51 struct _iconsole_var* _next; |
41 void * hook_before_exec; |
52 bool _malloc; |
42 void * hook_after_exec; |
53 } _iconsole_var; |
|
54 |
|
55 struct _iconsole_cmd; |
|
56 typedef bool (*iconsole_cmd_hook)(struct _iconsole_cmd* hook_cmd); |
|
57 |
|
58 typedef _iconsole_var* (*_iconsole_cmd_addr)(byte argc, char* argv[], byte argt[]); |
|
59 |
|
60 typedef struct _iconsole_cmd { |
43 // -------------- // |
61 // -------------- // |
44 void * _next; |
62 _iconsole_cmd_addr addr; |
45 } _iconsole_cmd; |
63 char* name; |
46 |
|
47 typedef struct { |
|
48 // --------------- // |
|
49 void * addr; |
|
50 const byte * name; |
|
51 byte type; |
|
52 // -------------- // |
64 // -------------- // |
53 void * hook_access; |
65 iconsole_cmd_hook hook_access; |
54 void * hook_before_change; |
66 iconsole_cmd_hook hook_before_exec; |
55 void * hook_after_change; |
67 iconsole_cmd_hook hook_after_exec; |
56 // -------------- // |
68 // -------------- // |
57 void * _next; |
69 void* _next; |
58 bool _malloc; |
70 } _iconsole_cmd; |
59 } _iconsole_var; |
|
60 |
71 |
61 // ** console parser ** // |
72 // ** console parser ** // |
62 |
73 |
63 _iconsole_cmd * _iconsole_cmds; // list of registred commands |
74 _iconsole_cmd* _iconsole_cmds; // list of registred commands |
64 _iconsole_var * _iconsole_vars; // list of registred vars |
75 _iconsole_var* _iconsole_vars; // list of registred vars |
65 |
76 |
66 // ** console colors ** // |
77 // ** console colors ** // |
67 VARDEF byte _iconsole_color_default; |
78 VARDEF byte _iconsole_color_default; |
68 VARDEF byte _iconsole_color_error; |
79 VARDEF byte _iconsole_color_error; |
69 VARDEF byte _iconsole_color_warning; |
80 VARDEF byte _iconsole_color_warning; |
70 VARDEF byte _iconsole_color_debug; |
81 VARDEF byte _iconsole_color_debug; |
71 VARDEF byte _iconsole_color_commands; |
82 VARDEF byte _iconsole_color_commands; |
72 |
83 |
73 // ** ttd.c functions ** // |
84 // ** ttd.c functions ** // |
74 |
85 |
75 void SetDebugString(const char *s); |
86 void SetDebugString(const char* s); |
76 |
87 |
77 // ** console functions ** // |
88 // ** console functions ** // |
78 |
89 |
79 void IConsoleClearCommand(); |
90 void IConsoleInit(void); |
80 void IConsoleInit(); |
91 void IConsoleClear(void); |
81 void IConsoleClear(); |
92 void IConsoleFree(void); |
82 void IConsoleFree(); |
93 void IConsoleResize(void); |
83 void IConsoleResize(); |
94 void IConsoleSwitch(void); |
84 void IConsoleSwitch(); |
95 void IConsoleClose(void); |
85 void IConsoleClose(); |
96 void IConsoleOpen(void); |
86 void IConsoleOpen(); |
|
87 |
97 |
88 // ** console cmd buffer ** // |
98 // ** console cmd buffer ** // |
89 void IConsoleCmdBufferAdd(const byte *cmd); |
99 void IConsoleCmdBufferAdd(const char* cmd); |
90 void IConsoleCmdBufferNavigate(signed char direction); |
100 void IConsoleCmdBufferNavigate(signed char direction); |
91 |
101 |
92 // ** console output ** // |
102 // ** console output ** // |
93 void IConsolePrint(byte color_code, const byte* string); |
103 void IConsolePrint(byte color_code, const char* string); |
94 void CDECL IConsolePrintF(byte color_code, const char *s, ...); |
104 void CDECL IConsolePrintF(byte color_code, const char* s, ...); |
95 void IConsoleDebug(byte* string); |
105 void IConsoleDebug(const char* string); |
96 void IConsoleError(const byte* string); |
106 void IConsoleError(const char* string); |
97 void IConsoleWarning(const byte* string); |
107 void IConsoleWarning(const char* string); |
98 |
108 |
99 // *** Commands *** // |
109 // *** Commands *** // |
100 |
110 |
101 void IConsoleCmdRegister(const byte * name, void * addr); |
111 void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr); |
102 _iconsole_cmd * IConsoleCmdGet(const byte * name); |
112 _iconsole_cmd* IConsoleCmdGet(const char* name); |
103 |
113 |
104 // *** Variables *** // |
114 // *** Variables *** // |
105 |
115 |
106 void IConsoleVarRegister(const byte * name, void * addr, byte type); |
116 void IConsoleVarRegister(const char* name, void* addr, _iconsole_var_types type); |
107 void IConsoleVarMemRegister(const byte * name, byte type); |
117 void IConsoleVarMemRegister(const char* name, _iconsole_var_types type); |
108 void IConsoleVarInsert(_iconsole_var * var, const byte * name); |
118 void IConsoleVarInsert(_iconsole_var* var, const char* name); |
109 _iconsole_var * IConsoleVarGet(const byte * name); |
119 _iconsole_var* IConsoleVarGet(const char* name); |
110 _iconsole_var * IConsoleVarAlloc(byte type); |
120 _iconsole_var* IConsoleVarAlloc(_iconsole_var_types type); |
111 void IConsoleVarFree(_iconsole_var * var); |
121 void IConsoleVarFree(_iconsole_var* var); |
112 void IConsoleVarSetString(_iconsole_var * var, const byte * string); |
122 void IConsoleVarSetString(_iconsole_var* var, const char* string); |
113 void IConsoleVarSetValue(_iconsole_var * var, int value); |
123 void IConsoleVarSetValue(_iconsole_var* var, int value); |
114 void IConsoleVarDump(_iconsole_var * var, const byte * dump_desc); |
124 void IConsoleVarDump(const _iconsole_var* var, const char* dump_desc); |
115 |
125 |
116 // *** Parser *** // |
126 // *** Parser *** // |
117 |
127 |
118 void IConsoleCmdExec(const byte* cmdstr); |
128 void IConsoleCmdExec(const char* cmdstr); |
119 |
129 |
120 // ** console std lib ** // |
130 // ** console std lib ** // |
121 void IConsoleStdLibRegister(); |
131 void IConsoleStdLibRegister(void); |
122 |
132 |
123 // ** hook code ** // |
133 // ** hook code ** // |
124 void IConsoleVarHook(const byte * name, byte type, void * proc); |
134 void IConsoleVarHook(const char* name, _iconsole_hook_types type, iconsole_var_hook proc); |
125 void IConsoleCmdHook(const byte * name, byte type, void * proc); |
135 void IConsoleCmdHook(const char* name, _iconsole_hook_types type, iconsole_cmd_hook proc); |
126 bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type); |
136 bool IConsoleVarHookHandle(_iconsole_var* hook_var, _iconsole_hook_types type); |
127 bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type); |
137 bool IConsoleCmdHookHandle(_iconsole_cmd* hook_cmd, _iconsole_hook_types type); |
128 |
138 |
129 #endif /* CONSOLE_H */ |
139 #endif /* CONSOLE_H */ |