1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1991-1997 S��ren Schmidt
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer
12 *    in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD$
31 */
32
33#ifndef _VGL_H_
34#define _VGL_H_
35
36#include <stdlib.h>
37#include <unistd.h>
38#include <string.h>
39#include <machine/cpufunc.h>
40
41typedef unsigned char byte;
42typedef struct {
43  byte 	Type;
44  int  	Xsize, Ysize;
45  int  	VXsize, VYsize;
46  int   Xorigin, Yorigin;
47  byte 	*Bitmap;
48  int	PixelBytes;
49} VGLBitmap;
50
51#define VGLBITMAP_INITIALIZER(t, x, y, bits)	\
52	{ (t), (x), (y), (x), (y), 0, 0, (bits), -1 }
53
54/*
55 * Defined Type's
56 */
57#define MEMBUF		0
58#define VIDBUF4		1
59#define VIDBUF8		2
60#define VIDBUF8X	3
61#define VIDBUF8S	4
62#define VIDBUF4S	5
63#define VIDBUF16	6		/* Direct Color linear buffer */
64#define VIDBUF24	7		/* Direct Color linear buffer */
65#define VIDBUF32	8		/* Direct Color linear buffer */
66#define VIDBUF16S	9		/* Direct Color segmented buffer */
67#define VIDBUF24S	10		/* Direct Color segmented buffer */
68#define VIDBUF32S	11		/* Direct Color segmented buffer */
69#define NOBUF		255
70
71typedef struct VGLText {
72  byte	Width, Height;
73  byte	*BitmapArray;
74} VGLText;
75
76typedef struct VGLObject {
77  int	  	Id;
78  int	  	Type;
79  int	  	Status;
80  int	  	Xpos, Ypos;
81  int	  	Xhot, Yhot;
82  VGLBitmap 	*Image;
83  VGLBitmap 	*Mask;
84  int		(*CallBackFunction)();
85} VGLObject;
86
87#define MOUSE_IMG_SIZE		16
88#define VGL_MOUSEHIDE		0
89#define VGL_MOUSESHOW		1
90#define VGL_MOUSEFREEZE		0
91#define VGL_MOUSEUNFREEZE	1
92#define VGL_DIR_RIGHT		0
93#define VGL_DIR_UP		1
94#define VGL_DIR_LEFT		2
95#define VGL_DIR_DOWN		3
96#define VGL_RAWKEYS		1
97#define VGL_CODEKEYS		2
98#define VGL_XLATEKEYS		3
99
100extern video_adapter_info_t	VGLAdpInfo;
101extern video_info_t		VGLModeInfo;
102extern VGLBitmap 		*VGLDisplay;
103extern VGLBitmap 		VGLVDisplay;
104extern byte 			*VGLBuf;
105
106/*
107 * Prototypes
108 */
109/* bitmap.c */
110int __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight);
111int VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight);
112VGLBitmap *VGLBitmapCreate(int type, int xsize, int ysize, byte *bits);
113void VGLBitmapDestroy(VGLBitmap *object);
114int VGLBitmapAllocateBits(VGLBitmap *object);
115void VGLBitmapCvt(VGLBitmap *src, VGLBitmap *dst);
116/* keyboard.c */
117int VGLKeyboardInit(int mode);
118void VGLKeyboardEnd(void);
119int VGLKeyboardGetCh(void);
120/* main.c */
121void VGLEnd(void);
122int VGLInit(int mode);
123void VGLCheckSwitch(void);
124int VGLSetVScreenSize(VGLBitmap *object, int VXsize, int VYsize);
125int VGLPanScreen(VGLBitmap *object, int x, int y);
126int VGLSetSegment(unsigned int offset);
127/* mouse.c */
128int __VGLMouseMode(int mode);
129void VGLMouseMode(int mode);
130void VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask);
131void VGLMouseSetStdImage(void);
132int VGLMouseInit(int mode);
133void VGLMouseRestore(void);
134int VGLMouseStatus(int *x, int *y, char *buttons);
135void VGLMouseFreeze(void);
136int VGLMouseFreezeXY(int x, int y);
137void VGLMouseMerge(int x, int y, int width, byte *line);
138int VGLMouseOverlap(int x, int y, int width, int hight);
139void VGLMouseUnFreeze(void);
140/* simple.c */
141void VGLSetXY(VGLBitmap *object, int x, int y, u_long color);
142u_long VGLGetXY(VGLBitmap *object, int x, int y);
143void VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
144void VGLBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
145void VGLFilledBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
146void VGLEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color);
147void VGLFilledEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color);
148void VGLClear(VGLBitmap *object, u_long color);
149u_long VGLrgb332ToNative(byte c);
150void VGLRestoreBlank(void);
151void VGLRestoreBorder(void);
152void VGLRestorePalette(void);
153void VGLSavePalette(void);
154void VGLSetPalette(byte *red, byte *green, byte *blue);
155void VGLSetPaletteIndex(byte color, byte red, byte green, byte blue);
156void VGLSetBorder(byte color);
157void VGLBlankDisplay(int blank);
158/* text.c */
159int VGLTextSetFontFile(char *filename);
160void VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch, u_long fgcol, u_long bgcol, int fill, int dir);
161void VGLBitmapString(VGLBitmap *Object, int x, int y, char *str, u_long fgcol, u_long bgcol, int fill, int dir);
162
163#endif /* !_VGL_H_ */
164