]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_head.h
wwww added timer!!
[16.git] / src / lib / 16_head.h
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #if !defined(__LARGE__) && !defined(__COMPACT__) && !defined(__HUGE__)
24 #error Invalid memory model for compiling project 16
25 #endif
26
27 #if !defined(__i86__) && defined(__i386__)
28 #error i8088 only
29 #endif
30
31 #ifndef _LIBHEAD_H_
32 #define _LIBHEAD_H_
33 #include <i86.h>
34 #include <dos.h>
35 #include <stdio.h>
36 #include <conio.h> // just for wait
37 #include <time.h> // just for wait
38 #include <stdlib.h>
39 #include <malloc.h>
40 #include <ctype.h>
41 #include <unistd.h>\r
42 #include <fcntl.h>\r
43 #include <sys/stat.h>
44 #include <mem.h>
45 #include "src/lib/types.h"
46
47 /* Control codes for all keys on the keyboard */
48 //here temperarly
49 /*
50 #define KEY_A           (0x1E)
51 #define KEY_B           (0x30)
52 #define KEY_C           (0x2E)
53 #define KEY_D           (0x20)
54 #define KEY_E           (0x12)
55 #define KEY_F           (0x21)
56 #define KEY_G           (0x22)
57 #define KEY_H           (0x23)
58 #define KEY_I           (0x17)
59 #define KEY_J           (0x24)
60 #define KEY_K           (0x25)
61 #define KEY_L           (0x26)
62 #define KEY_M           (0x32)
63 #define KEY_N           (0x31)
64 #define KEY_O           (0x18)
65 #define KEY_P           (0x19)
66 #define KEY_Q           (0x10)
67 #define KEY_R           (0x13)
68 #define KEY_S           (0x1F)
69 #define KEY_T           (0x14)
70 #define KEY_U           (0x16)
71 #define KEY_V           (0x2F)
72 #define KEY_W           (0x11)
73 #define KEY_X           (0x2D)
74 #define KEY_Y           (0x15)
75 #define KEY_Z           (0x2C)
76 #define KEY_1           (0x02)
77 #define KEY_2           (0x03)
78 #define KEY_3           (0x04)
79 #define KEY_4           (0x05)
80 #define KEY_5           (0x06)
81 #define KEY_6           (0x07)
82 #define KEY_7           (0x08)
83 #define KEY_8           (0x09)
84 #define KEY_9           (0x0A)
85 #define KEY_0           (0x0B)
86 #define KEY_DASH                (0x0C)  // -_
87 #define KEY_EQUAL               (0x0D)  // =+
88 #define KEY_LBRACKET    (0x1A)  // [{
89 #define KEY_RBRACKET    (0x1B)  // ]}
90 #define KEY_SEMICOLON   (0x27)  // ;:
91 #define KEY_RQUOTE      (0x28)  // '"
92 #define KEY_LQUOTE      (0x29)  // `~
93 #define KEY_PERIOD      (0x33)  // .>
94 #define KEY_COMMA               (0x34)  // ,<
95 #define KEY_SLASH               (0x35)  // /?
96 #define KEY_BACKSLASH   (0x2B)  // \|
97 #define KEY_F1          (0x3B)
98 #define KEY_F2          (0x3C)
99 #define KEY_F3          (0x3D)
100 #define KEY_F4          (0x3E)
101 #define KEY_F5          (0x3F)
102 #define KEY_F6          (0x40)
103 #define KEY_F7          (0x41)
104 #define KEY_F8          (0x42)
105 #define KEY_F9          (0x43)
106 #define KEY_F10         (0x44)
107 #define KEY_ESC         (0x01)
108 #define KEY_BACKSPACE   (0x0E)
109 #define KEY_TAB         (0x0F)
110 #define KEY_ENTER               (0x1C)
111 #define KEY_CONTROL     (0x1D)
112 #define KEY_LSHIFT      (0x2A)
113 #define KEY_RSHIFT      (0x36)
114 #define KEY_PRTSC               (0x37)
115 #define KEY_ALT         (0x38)
116 #define KEY_SPACE               (0x39)
117 #define KEY_CAPSLOCK    (0x3A)
118 #define KEY_NUMLOCK     (0x45)
119 #define KEY_SCROLLLOCK  (0x46)
120 #define KEY_HOME                (0x47)
121 #define KEY_UP          (0x48)
122 #define KEY_PGUP                (0x49)
123 #define KEY_MINUS               (0x4A)
124 #define KEY_LEFT                (0x4B)
125 #define KEY_CENTER      (0x4C)
126 #define KEY_RIGHT               (0x4D)
127 #define KEY_PLUS                (0x4E)
128 #define KEY_END         (0x4F)
129 #define KEY_DOWN                (0x50)
130 #define KEY_PGDOWN      (0x51)
131 #define KEY_INS         (0x52)
132 #define KEY_DEL         (0x53)
133
134 #define KEY_LWIN                (0x73)
135 #define KEY_RWIN                (0x74)
136 #define KEY_MENU                (0x75)
137 */
138
139 static dword far* clockdw= (dword far*) 0x046C; /* 18.2hz clock */
140 //static dword clockdw=0;
141 extern  int                     profilehandle,debughandle;      //make it into game global
142
143 #define __DEBUG__
144
145 //#define _SEGU(__p) ((unsigned)((unsigned long)(void __huge*)(__p) >> 16))
146
147 #define nil     ((void *)0)
148
149 #define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs)))\r
150 #define peekw(segm,ofs) (*(word far*)MK_FP((segm),(ofs)))\r
151 #define pokeb(segm,ofs,value) (peekb((segm),(ofs)) = (byte)(value))\r
152 #define pokew(segm,ofs,value) (peekw((segm),(ofs)) = (word)(value))\r
153
154 typedef union REGPACK   regs_t;
155 //typedef struct SREGS sregs_t;
156 //sregs_t sregs;
157 typedef enum    {false,true}    boolean;
158 //I hope this is correct!
159 typedef void __based(__self) * memptr;
160 //typedef sregs.w.es * memptr
161 //typedef __segment * memptr;
162 //typedef fenp.op_ptr_seg * memptr;
163 typedef struct
164 {\r
165         int old_mode;   //old video mode before game!
166         word frames_per_second;
167         clock_t t;
168 } global_game_variables_t;\r
169
170 /* local function */\r
171 void wait(clock_t wait);
172 void* AllocateLargestFreeBlock(size_t* Size);
173 size_t GetFreeSize(void);
174 void far *AllocateLargestFarFreeBlock(size_t far* Size);
175 size_t GetFarFreeSize(void);
176 void __near *AllocateLargestNearFreeBlock(size_t* Size);
177 size_t GetNearFreeSize(void);
178 long int filesize(FILE *fp);
179 int US_CheckParm(char *parm,char **strings);
180
181 extern void CA_OpenDebug (void);\r
182 extern void CA_CloseDebug (void);
183
184 #endif/*_LIBHEAD_H_*/