]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_t.h
ff73865751b57b0a984f94756819344b50a5bd76
[16.git] / src / lib / 16_t.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 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 \r
53 on usage where you need pointer convert memseg type (segment) to far pointer by\r
54 MK_FP(segment value, 0)*/\r
55 #ifdef __WATCOMC__\r
56 //typedef void __based( void ) * memptr;        ////old //----typedef void __based(__self) * memptr;\r
57 //typedef unsigned short _seg; // it will contains segment value (as Borland _seg)\r
58 #define _seg __based( void )\r
59 // #define __SEGA __segment\r
60 #endif\r
61 #ifdef __BORLANDC__\r
62 #define _memavl()               coreleft()\r
63 // #define __SEGA _seg\r
64 #endif\r
65 \r
66 typedef void _seg * memptr;\r
67 \r
68 #define MEMPTRCONV                      (memptr *)&\r
69 \r
70 //bcc\r
71 #ifdef __BORLANDC__\r
72 #define MEMPTRANDPERCONV        &\r
73 //#define BYTEFARPTRCONV                (unsigned char far *)\r
74 //#define SMDPTRANDPERCONV      &\r
75 //#define SDFPTRANDPERCONV      &\r
76 //#define OBTPTRANDPERCONV      &\r
77 //#define SDTPTRANDPERCONV      &\r
78 #endif\r
79 //\r
80 \r
81 //wcc\r
82 #ifdef __WATCOMC__      //functions found in borland c but not watcom c\r
83 #define MEMPTRANDPERCONV\r
84 //#define BYTEFARPTRCONV\r
85 //#define SMDPTRANDPERCONV      (void *)&\r
86 //#define SDFPTRANDPERCONV      (struct diskfree_t *)&\r
87 //#define OBTPTRANDPERCONV      (void const *)&\r
88 //#define SDTPTRANDPERCONV      (struct dostime_t *)&\r
89 \r
90 #define _argv __argv\r
91 #define _argc __argc\r
92 #define EINVFMT EMFILE\r
93 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);\r
94 \r
95 #define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs)))\r
96 #define peek(segm,ofs) (*(word far*)MK_FP((segm),(ofs)))\r
97 #define pokeb(segm,ofs,value) (peekb((segm),(ofs)) = (byte)(value))\r
98 #define poke(segm,ofs,value) (peek((segm),(ofs)) = (word)(value))\r
99 \r
100 #define inportb(port)           inp(port)\r
101 #define inport(port)            inpw(port)\r
102 #define outportb(port, val)     outp(port, val)\r
103 #define outport(port, val)      outpw(port, val)\r
104 \r
105 #define asm __asm\r
106 #define getvect _dos_getvect\r
107 #define setvect _dos_setvect\r
108 \r
109 //from http://www.verycomputer.com/3_65d875cc818b54ec_1.htm\r
110 void clrscr(void);\r
111 #pragma aux clrscr= \\r
112   " mov ah, 0fh " \\r
113   " int 10h " \\r
114   " xor ah, ah " \\r
115   " int 10h " ;\r
116 //from http://stackoverflow.com/questions/18425748/gotoxy-function-using-printf-s-position\r
117 inline void gotoxy(int x,int y)\r
118 {\r
119         printf("\x1B[%d;%df", y, x);\r
120         fflush(stdout);  // @jxh\r
121 }\r
122 #endif\r
123 \r
124 #endif/*_TYPE_H_*/\r