OSDN Git Service

updated copyright. i am not dead just busy. i am working more on wolfenstien 3d and...
[proj16/16.git] / src / lib / 16_t.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2020 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 /*\r
23  * Just some handy typedefs that make it easier to think about the low\r
24  * level code\r
25  */\r
26 \r
27 #ifndef _TYPE_H_\r
28 #define _TYPE_H_\r
29 \r
30 typedef unsigned char byte;\r
31 typedef unsigned short word;\r
32 typedef unsigned long dword;\r
33 typedef signed char sbyte;\r
34 typedef signed short sword;\r
35 typedef signed long sdword;\r
36 \r
37 typedef unsigned int iword;\r
38 typedef signed int siword;\r
39 \r
40 typedef unsigned long int diword;\r
41 typedef signed long int sdiword;\r
42 \r
43 typedef enum    {false,true}    boolean;\r
44 typedef enum    {ichi,ni,san,yon,go,roku,shichi,hachi,kyu,ju,juichi,juni,jusan,juyon,jugo,juroku}       nibble;\r
45 //typedef       unsigned nibb:4 nibble;\r
46 \r
47 #define HI_NIBBLE(b) (((b) >> 4) & 0x0F)\r
48 #define LO_NIBBLE(b) ((b) & 0x0F)\r
49 /*typedef unsigned memseg;\r
50 \r
51 memptr should be replaced by memseg in code.\r
52 on usage where you need pointer convert memseg type (segment) to far pointer by\r
53 MK_FP(segment value, 0)*/\r
54         #ifdef __WATCOMC__\r
55 //typedef void __based( void ) * memptr;        ////old //----typedef void __based(__self) * memptr;\r
56 //typedef unsigned short _seg; // it will contains segment value (as Borland _seg)\r
57 #define _seg __based( void )\r
58         #endif\r
59 \r
60 typedef void _seg * memptr;\r
61 \r
62 #define MEMPTRCONV                      (memptr *)&\r
63 \r
64 //bcc\r
65 #ifdef __BORLANDC__\r
66 #define MEMPTRANDPERCONV        &\r
67 //#define BYTEFARPTRCONV                (unsigned char far *)\r
68 //#define SMDPTRANDPERCONV      &\r
69 //#define SDFPTRANDPERCONV      &\r
70 //#define OBTPTRANDPERCONV      &\r
71 //#define SDTPTRANDPERCONV      &\r
72 \r
73 #define _nmalloc malloc\r
74 #define _nfree free\r
75 \r
76 #define _nheapwalk heapwalk\r
77 #define _fheapwalk farheapwalk\r
78 \r
79 //heapinfo vars\r
80 #define _heapinfo heapinfo\r
81 #define _pentry ptr\r
82 #define _size   size\r
83 #define _useflag        in_use\r
84 #endif\r
85 //\r
86 \r
87 //wcc\r
88 #ifdef __WATCOMC__      //functions found in borland c but not watcom c\r
89 #define MEMPTRANDPERCONV\r
90 //#define BYTEFARPTRCONV\r
91 //#define SMDPTRANDPERCONV      (void *)&\r
92 //#define SDFPTRANDPERCONV      (struct diskfree_t *)&\r
93 //#define OBTPTRANDPERCONV      (void const *)&\r
94 //#define SDTPTRANDPERCONV      (struct dostime_t *)&\r
95 \r
96 #define _argv __argv\r
97 #define _argc __argc\r
98 #define EINVFMT EMFILE\r
99 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);\r
100 \r
101 #define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs)))\r
102 #define peek(segm,ofs) (*(word far*)MK_FP((segm),(ofs)))\r
103 #define pokeb(segm,ofs,value) (peekb((segm),(ofs)) = (byte)(value))\r
104 #define poke(segm,ofs,value) (peek((segm),(ofs)) = (word)(value))\r
105 \r
106 #define inportb(port)           inp(port)\r
107 #define inport(port)            inpw(port)\r
108 #define outportb(port, val)     outp(port, val)\r
109 #define outport(port, val)      outpw(port, val)\r
110 \r
111 #define asm __asm\r
112 #define getvect _dos_getvect\r
113 #define setvect _dos_setvect\r
114 \r
115 #define farmalloc _fmalloc\r
116 #define farfree _ffree\r
117 #define nearmalloc _nmalloc\r
118 #define nearfree _nfree\r
119 \r
120 //from http://www.verycomputer.com/3_65d875cc818b54ec_1.htm\r
121 void clrscr(void);\r
122 #pragma aux clrscr=\\r
123         " mov ah, 0fh "\\r
124         " int 10h "\\r
125         " xor ah, ah "\\r
126         " int 10h ";\r
127 \r
128 //from http://stackoverflow.com/questions/18425748/gotoxy-function-using-printf-s-position\r
129 inline void gotoxy(int x,int y)\r
130 {\r
131         printf("\x1B[%d;%df", y, x);\r
132         fflush(stdout);  // @jxh\r
133 }\r
134 #endif\r
135 \r
136 #define PFDT    printf(".");\r
137 \r
138 #endif/*_TYPE_H_*/\r