/*-
 * Copyright (c) 2006 Robert N. M. Watson
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef _BORLAND_H_
#define	_BORLAND_H_

/*
 * UNIX doesn't know or care about any of this nonsense.
 */
#ifndef far
#define	far
#endif
#ifndef interrupt
#define	interrupt
#endif
#ifndef huge
#define	huge
#endif

/*
 * _FOO register declaration dummies.
 */
extern unsigned int	_AX;
extern unsigned short	_AH;
extern unsigned short	_AL;
extern unsigned int	_BX;
extern unsigned short	_BH;
extern unsigned short	_BL;
extern unsigned int	_CX;
extern unsigned short	_CH;
extern unsigned short	_CL;
extern unsigned int	_DX;
extern unsigned short	_DH;
extern unsigned short	_DL;
extern unsigned int	_DS;
extern unsigned int	_SS;
extern unsigned int	_SP;

/*
 * Borland C memory allocation and pointer-related functions/macros.
 */
void	*farmalloc(unsigned long size);
void	 farfree(void *ptr);

#define	MK_FP(x, y)	/* ((x) * 1<<15 + (y)) */ NULL
#define	FP_OFF(x)	((uintptr_t)&(x))
#define	FP_SEG(x)	(0)

/*
 * Borland C string functions.
 */
char	*gcvt(double value, int num, char *buffer);
char	*itoa(int value, char *buffer, int radix);
char	*ltoa(long value, char *buffer, int radix);
int	 stricmp(const char *s1, const char *s2);
char	*strupr(char *string);
char	*ultoa(unsigned long value, char *buffer, int radix);

/*
 * Non-portable I/O functions.
 */
int	getch(void);
int	getche(void);
int	peek(unsigned int segment, unsigned int offset);
char	peekb(unsigned int segment, unsigned int offset);

#endif /* !_BORLAND_H_ */
