Rev 56 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
56 | pj | 1 | /* |
2 | * PC/HW routine collection v1.2 for DOS/DJGPP |
||
3 | * |
||
4 | * Copyright (C) 2002 - Borca Daniel |
||
5 | * Email : dborca@yahoo.com |
||
6 | * Web : http://www.geocities.com/dborca |
||
7 | */ |
||
8 | |||
9 | |||
10 | #ifndef PC_HW_H_included |
||
11 | #define PC_HW_H_included |
||
12 | |||
13 | //#include <dpmi.h> //SHARK |
||
14 | #include <stdlib.h> |
||
15 | |||
16 | /* |
||
17 | * misc C definitions |
||
18 | */ |
||
86 | giacomo | 19 | #ifdef FALSE |
20 | #undef FALSE |
||
21 | #endif |
||
56 | pj | 22 | #define FALSE 0 |
86 | giacomo | 23 | #ifdef TRUE |
24 | #undef TRUE |
||
25 | #endif |
||
56 | pj | 26 | #define TRUE !FALSE |
27 | |||
28 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) |
||
29 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) |
||
30 | #define MID(x,y,z) MAX((x), MIN((y), (z))) |
||
31 | |||
32 | typedef void (*VFUNC) (void); |
||
33 | typedef void (*PFUNC) (void *); |
||
34 | typedef void (*MFUNC) (int x, int y, int b); |
||
35 | |||
36 | /* |
||
37 | * atexit |
||
38 | */ |
||
39 | int pc_atexit (VFUNC f); |
||
40 | int pc_clexit (VFUNC f); |
||
41 | |||
42 | /* |
||
43 | * locked memory |
||
44 | */ |
||
45 | #define ENDOFUNC(x) static void x##_end() { } |
||
46 | #define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x) |
||
47 | #define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x)) |
||
48 | |||
49 | void *pc_malloc (size_t size); |
||
50 | |||
51 | /* |
||
52 | * IRQ |
||
53 | */ |
||
54 | #define ENABLE() __asm __volatile ("sti") |
||
55 | #define DISABLE() __asm __volatile ("cli") |
||
56 | |||
57 | extern int pc_install_irq (int i, int (*handler) ()); |
||
58 | extern int pc_remove_irq (int i); |
||
59 | |||
60 | /* |
||
61 | * keyboard |
||
62 | */ |
||
63 | #define KB_SHIFT_FLAG 0x0001 |
||
64 | #define KB_CTRL_FLAG 0x0002 |
||
65 | #define KB_ALT_FLAG 0x0004 |
||
66 | #define KB_LWIN_FLAG 0x0008 |
||
67 | #define KB_RWIN_FLAG 0x0010 |
||
68 | #define KB_MENU_FLAG 0x0020 |
||
69 | #define KB_SCROLOCK_FLAG 0x0100 |
||
70 | #define KB_NUMLOCK_FLAG 0x0200 |
||
71 | #define KB_CAPSLOCK_FLAG 0x0400 |
||
72 | #define KB_INALTSEQ_FLAG 0x0800 |
||
73 | #define KB_ACCENT1_FLAG 0x1000 |
||
74 | #define KB_ACCENT2_FLAG 0x2000 |
||
75 | #define KB_ACCENT3_FLAG 0x4000 |
||
76 | #define KB_ACCENT4_FLAG 0x8000 |
||
77 | |||
78 | #define KEY_A 1 |
||
79 | #define KEY_B 2 |
||
80 | #define KEY_C 3 |
||
81 | #define KEY_D 4 |
||
82 | #define KEY_E 5 |
||
83 | #define KEY_F 6 |
||
84 | #define KEY_G 7 |
||
85 | #define KEY_H 8 |
||
86 | #define KEY_I 9 |
||
87 | #define KEY_J 10 |
||
88 | #define KEY_K 11 |
||
89 | #define KEY_L 12 |
||
90 | #define KEY_M 13 |
||
91 | #define KEY_N 14 |
||
92 | #define KEY_O 15 |
||
93 | #define KEY_P 16 |
||
94 | #define KEY_Q 17 |
||
95 | #define KEY_R 18 |
||
96 | #define KEY_S 19 |
||
97 | #define KEY_T 20 |
||
98 | #define KEY_U 21 |
||
99 | #define KEY_V 22 |
||
100 | #define KEY_W 23 |
||
101 | #define KEY_X 24 |
||
102 | #define KEY_Y 25 |
||
103 | #define KEY_Z 26 |
||
104 | #define KEY_0 27 |
||
105 | #define KEY_1 28 |
||
106 | #define KEY_2 29 |
||
107 | #define KEY_3 30 |
||
108 | #define KEY_4 31 |
||
109 | #define KEY_5 32 |
||
110 | #define KEY_6 33 |
||
111 | #define KEY_7 34 |
||
112 | #define KEY_8 35 |
||
113 | #define KEY_9 36 |
||
114 | #define KEY_0_PAD 37 |
||
115 | #define KEY_1_PAD 38 |
||
116 | #define KEY_2_PAD 39 |
||
117 | #define KEY_3_PAD 40 |
||
118 | #define KEY_4_PAD 41 |
||
119 | #define KEY_5_PAD 42 |
||
120 | #define KEY_6_PAD 43 |
||
121 | #define KEY_7_PAD 44 |
||
122 | #define KEY_8_PAD 45 |
||
123 | #define KEY_9_PAD 46 |
||
124 | #define KEY_F1 47 |
||
125 | #define KEY_F2 48 |
||
126 | #define KEY_F3 49 |
||
127 | #define KEY_F4 50 |
||
128 | #define KEY_F5 51 |
||
129 | #define KEY_F6 52 |
||
130 | #define KEY_F7 53 |
||
131 | #define KEY_F8 54 |
||
132 | #define KEY_F9 55 |
||
133 | #define KEY_F10 56 |
||
134 | #define KEY_F11 57 |
||
135 | #define KEY_F12 58 |
||
136 | #define KEY_ESC 59 |
||
137 | #define KEY_TILDE 60 |
||
138 | #define KEY_MINUS 61 |
||
139 | #define KEY_EQUALS 62 |
||
140 | #define KEY_BACKSPACE 63 |
||
141 | #define KEY_TAB 64 |
||
142 | #define KEY_OPENBRACE 65 |
||
143 | #define KEY_CLOSEBRACE 66 |
||
144 | #define KEY_ENTER 67 |
||
145 | #define KEY_COLON 68 |
||
146 | #define KEY_QUOTE 69 |
||
147 | #define KEY_BACKSLASH 70 |
||
148 | #define KEY_BACKSLASH2 71 |
||
149 | #define KEY_COMMA 72 |
||
150 | #define KEY_STOP 73 |
||
151 | #define KEY_SLASH 74 |
||
152 | #define KEY_SPACE 75 |
||
153 | #define KEY_INSERT 76 |
||
154 | #define KEY_DEL 77 |
||
155 | #define KEY_HOME 78 |
||
156 | #define KEY_END 79 |
||
157 | #define KEY_PGUP 80 |
||
158 | #define KEY_PGDN 81 |
||
159 | #define KEY_LEFT 82 |
||
160 | #define KEY_RIGHT 83 |
||
161 | #define KEY_UP 84 |
||
162 | #define KEY_DOWN 85 |
||
163 | #define KEY_SLASH_PAD 86 |
||
164 | #define KEY_ASTERISK 87 |
||
165 | #define KEY_MINUS_PAD 88 |
||
166 | #define KEY_PLUS_PAD 89 |
||
167 | #define KEY_DEL_PAD 90 |
||
168 | #define KEY_ENTER_PAD 91 |
||
169 | #define KEY_PRTSCR 92 |
||
170 | #define KEY_PAUSE 93 |
||
171 | #define KEY_ABNT_C1 94 |
||
172 | #define KEY_YEN 95 |
||
173 | #define KEY_KANA 96 |
||
174 | #define KEY_CONVERT 97 |
||
175 | #define KEY_NOCONVERT 98 |
||
176 | #define KEY_AT 99 |
||
177 | #define KEY_CIRCUMFLEX 100 |
||
178 | #define KEY_COLON2 101 |
||
179 | #define KEY_KANJI 102 |
||
180 | |||
181 | #define KEY_MODIFIERS 103 |
||
182 | |||
183 | #define KEY_LSHIFT 103 |
||
184 | #define KEY_RSHIFT 104 |
||
185 | #define KEY_LCONTROL 105 |
||
186 | #define KEY_RCONTROL 106 |
||
187 | #define KEY_ALT 107 |
||
188 | #define KEY_ALTGR 108 |
||
189 | #define KEY_LWIN 109 |
||
190 | #define KEY_RWIN 110 |
||
191 | #define KEY_MENU 111 |
||
192 | #define KEY_SCRLOCK 112 |
||
193 | #define KEY_NUMLOCK 113 |
||
194 | #define KEY_CAPSLOCK 114 |
||
195 | |||
196 | #define KEY_MAX 115 |
||
197 | |||
198 | int pc_install_keyb (void); |
||
199 | void pc_remove_keyb (void); |
||
200 | int pc_keypressed (void); |
||
201 | int pc_readkey (void); |
||
202 | int pc_keydown (int code); |
||
203 | |||
204 | /* |
||
205 | * timer |
||
206 | */ |
||
207 | int pc_install_int (PFUNC func, void *parm, unsigned int freq); |
||
208 | void pc_remove_timer (void); |
||
209 | |||
210 | /* |
||
211 | * mouse |
||
212 | */ |
||
213 | int pc_install_mouse (void); |
||
214 | void pc_remove_mouse (void); |
||
215 | MFUNC pc_install_mouse_handler (MFUNC handler); |
||
216 | void pc_mouse_area (int x1, int y1, int x2, int y2); |
||
217 | void pc_mouse_speed (int xspeed, int yspeed); |
||
218 | int pc_query_mouse (int *x, int *y); |
||
219 | void pc_show_mouse (void); |
||
220 | void pc_scare_mouse (void); |
||
221 | void pc_unscare_mouse (void); |
||
222 | |||
223 | /* |
||
224 | * standard redirection |
||
225 | */ |
||
226 | int pc_open_stdout (void); |
||
227 | int pc_open_stderr (void); |
||
228 | void pc_close_stdout (void); |
||
229 | void pc_close_stderr (void); |
||
230 | |||
231 | #endif |