1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
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
23 * Just some handy typedefs that make it easier to think about the low
\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
37 typedef unsigned int iword;
\r
38 typedef signed int siword;
\r
40 typedef unsigned long int diword;
\r
41 typedef signed long int sdiword;
\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
47 #define HI_NIBBLE(b) (((b) >> 4) & 0x0F)
\r
48 #define LO_NIBBLE(b) ((b) & 0x0F)
\r
49 /*typedef unsigned memseg;
\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
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
60 typedef void _seg * memptr;
\r
62 #define MEMPTRCONV (memptr *)&
\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
73 #define _nmalloc malloc
\r
76 #define _nheapwalk heapwalk
\r
77 #define _fheapwalk farheapwalk
\r
80 #define _heapinfo heapinfo
\r
83 #define _useflag in_use
\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
96 #define _argv __argv
\r
97 #define _argc __argc
\r
98 #define EINVFMT EMFILE
\r
99 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);
\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
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
112 #define getvect _dos_getvect
\r
113 #define setvect _dos_setvect
\r
115 #define farmalloc _fmalloc
\r
116 #define farfree _ffree
\r
117 #define nearmalloc _nmalloc
\r
118 #define nearfree _nfree
\r
120 //from http://www.verycomputer.com/3_65d875cc818b54ec_1.htm
\r
122 #pragma aux clrscr=\
\r
128 //from http://stackoverflow.com/questions/18425748/gotoxy-function-using-printf-s-position
\r
129 inline void gotoxy(int x,int y)
\r
131 printf("\x1B[%d;%df", y, x);
\r
132 fflush(stdout); // @jxh
\r