xref: /freebsd/lib/libvgl/vgl.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
19a57b7d2SSøren Schmidt /*-
25e53a4f9SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
35e53a4f9SPedro F. Giffuni  *
4bf3f9db6SUlrich Spörlein  * Copyright (c) 1991-1997 Søren Schmidt
59a57b7d2SSøren Schmidt  * All rights reserved.
69a57b7d2SSøren Schmidt  *
79a57b7d2SSøren Schmidt  * Redistribution and use in source and binary forms, with or without
89a57b7d2SSøren Schmidt  * modification, are permitted provided that the following conditions
99a57b7d2SSøren Schmidt  * are met:
109a57b7d2SSøren Schmidt  * 1. Redistributions of source code must retain the above copyright
119a57b7d2SSøren Schmidt  *    notice, this list of conditions and the following disclaimer
129a57b7d2SSøren Schmidt  *    in this position and unchanged.
139a57b7d2SSøren Schmidt  * 2. Redistributions in binary form must reproduce the above copyright
149a57b7d2SSøren Schmidt  *    notice, this list of conditions and the following disclaimer in the
159a57b7d2SSøren Schmidt  *    documentation and/or other materials provided with the distribution.
169a57b7d2SSøren Schmidt  * 3. The name of the author may not be used to endorse or promote products
1721dc7d4fSJens Schweikhardt  *    derived from this software without specific prior written permission
189a57b7d2SSøren Schmidt  *
199a57b7d2SSøren Schmidt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
209a57b7d2SSøren Schmidt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
219a57b7d2SSøren Schmidt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
229a57b7d2SSøren Schmidt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
239a57b7d2SSøren Schmidt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
249a57b7d2SSøren Schmidt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
259a57b7d2SSøren Schmidt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
269a57b7d2SSøren Schmidt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
279a57b7d2SSøren Schmidt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
289a57b7d2SSøren Schmidt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
299a57b7d2SSøren Schmidt  */
309a57b7d2SSøren Schmidt 
310e2fa3bbSMaxim Sobolev #ifndef _VGL_H_
320e2fa3bbSMaxim Sobolev #define _VGL_H_
330e2fa3bbSMaxim Sobolev 
349a57b7d2SSøren Schmidt #include <stdlib.h>
359a57b7d2SSøren Schmidt #include <unistd.h>
369a57b7d2SSøren Schmidt #include <string.h>
379a57b7d2SSøren Schmidt #include <machine/cpufunc.h>
389a57b7d2SSøren Schmidt 
399a57b7d2SSøren Schmidt typedef unsigned char byte;
409a57b7d2SSøren Schmidt typedef struct {
419a57b7d2SSøren Schmidt   byte 	Type;
429a57b7d2SSøren Schmidt   int  	Xsize, Ysize;
435acf51eaSKazutaka YOKOTA   int  	VXsize, VYsize;
445acf51eaSKazutaka YOKOTA   int   Xorigin, Yorigin;
459a57b7d2SSøren Schmidt   byte 	*Bitmap;
46933d455fSNicolas Souchu   int	PixelBytes;
479a57b7d2SSøren Schmidt } VGLBitmap;
489a57b7d2SSøren Schmidt 
495acf51eaSKazutaka YOKOTA #define VGLBITMAP_INITIALIZER(t, x, y, bits)	\
50fbc6daa1SBruce Evans 	{ (t), (x), (y), (x), (y), 0, 0, (bits), -1 }
515acf51eaSKazutaka YOKOTA 
529a57b7d2SSøren Schmidt /*
539a57b7d2SSøren Schmidt  * Defined Type's
549a57b7d2SSøren Schmidt  */
559a57b7d2SSøren Schmidt #define MEMBUF		0
569a57b7d2SSøren Schmidt #define VIDBUF4		1
579a57b7d2SSøren Schmidt #define VIDBUF8		2
589a57b7d2SSøren Schmidt #define VIDBUF8X	3
595acf51eaSKazutaka YOKOTA #define VIDBUF8S	4
605acf51eaSKazutaka YOKOTA #define VIDBUF4S	5
61933d455fSNicolas Souchu #define VIDBUF16	6		/* Direct Color linear buffer */
62933d455fSNicolas Souchu #define VIDBUF24	7		/* Direct Color linear buffer */
63933d455fSNicolas Souchu #define VIDBUF32	8		/* Direct Color linear buffer */
64933d455fSNicolas Souchu #define VIDBUF16S	9		/* Direct Color segmented buffer */
65933d455fSNicolas Souchu #define VIDBUF24S	10		/* Direct Color segmented buffer */
66933d455fSNicolas Souchu #define VIDBUF32S	11		/* Direct Color segmented buffer */
679a57b7d2SSøren Schmidt #define NOBUF		255
689a57b7d2SSøren Schmidt 
699a57b7d2SSøren Schmidt typedef struct VGLText {
709a57b7d2SSøren Schmidt   byte	Width, Height;
719a57b7d2SSøren Schmidt   byte	*BitmapArray;
729a57b7d2SSøren Schmidt } VGLText;
739a57b7d2SSøren Schmidt 
749a57b7d2SSøren Schmidt typedef struct VGLObject {
759a57b7d2SSøren Schmidt   int	  	Id;
769a57b7d2SSøren Schmidt   int	  	Type;
779a57b7d2SSøren Schmidt   int	  	Status;
789a57b7d2SSøren Schmidt   int	  	Xpos, Ypos;
799a57b7d2SSøren Schmidt   int	  	Xhot, Yhot;
809a57b7d2SSøren Schmidt   VGLBitmap 	*Image;
819a57b7d2SSøren Schmidt   VGLBitmap 	*Mask;
829a57b7d2SSøren Schmidt   int		(*CallBackFunction)();
839a57b7d2SSøren Schmidt } VGLObject;
849a57b7d2SSøren Schmidt 
859a57b7d2SSøren Schmidt #define MOUSE_IMG_SIZE		16
869a57b7d2SSøren Schmidt #define VGL_MOUSEHIDE		0
879a57b7d2SSøren Schmidt #define VGL_MOUSESHOW		1
889a57b7d2SSøren Schmidt #define VGL_MOUSEFREEZE		0
899a57b7d2SSøren Schmidt #define VGL_MOUSEUNFREEZE	1
909a57b7d2SSøren Schmidt #define VGL_DIR_RIGHT		0
919a57b7d2SSøren Schmidt #define VGL_DIR_UP		1
929a57b7d2SSøren Schmidt #define VGL_DIR_LEFT		2
939a57b7d2SSøren Schmidt #define VGL_DIR_DOWN		3
94b478da36SSøren Schmidt #define VGL_RAWKEYS		1
95b478da36SSøren Schmidt #define VGL_CODEKEYS		2
96b478da36SSøren Schmidt #define VGL_XLATEKEYS		3
979a57b7d2SSøren Schmidt 
985acf51eaSKazutaka YOKOTA extern video_adapter_info_t	VGLAdpInfo;
995acf51eaSKazutaka YOKOTA extern video_info_t		VGLModeInfo;
1009a57b7d2SSøren Schmidt extern VGLBitmap 		*VGLDisplay;
1011fa51420SBruce Evans extern VGLBitmap 		VGLVDisplay;
1025acf51eaSKazutaka YOKOTA extern byte 			*VGLBuf;
1039a57b7d2SSøren Schmidt 
1049a57b7d2SSøren Schmidt /*
1059a57b7d2SSøren Schmidt  * Prototypes
1069a57b7d2SSøren Schmidt  */
1079a57b7d2SSøren Schmidt /* bitmap.c */
1089a57b7d2SSøren Schmidt int __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight);
1099a57b7d2SSøren Schmidt int VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight);
1105acf51eaSKazutaka YOKOTA VGLBitmap *VGLBitmapCreate(int type, int xsize, int ysize, byte *bits);
1115acf51eaSKazutaka YOKOTA void VGLBitmapDestroy(VGLBitmap *object);
1125acf51eaSKazutaka YOKOTA int VGLBitmapAllocateBits(VGLBitmap *object);
113a93ca07aSBruce Evans void VGLBitmapCvt(VGLBitmap *src, VGLBitmap *dst);
114b478da36SSøren Schmidt /* keyboard.c */
115b478da36SSøren Schmidt int VGLKeyboardInit(int mode);
116b478da36SSøren Schmidt void VGLKeyboardEnd(void);
117b478da36SSøren Schmidt int VGLKeyboardGetCh(void);
1189a57b7d2SSøren Schmidt /* main.c */
1199a57b7d2SSøren Schmidt void VGLEnd(void);
1209a57b7d2SSøren Schmidt int VGLInit(int mode);
1219a57b7d2SSøren Schmidt void VGLCheckSwitch(void);
1225acf51eaSKazutaka YOKOTA int VGLSetVScreenSize(VGLBitmap *object, int VXsize, int VYsize);
1235acf51eaSKazutaka YOKOTA int VGLPanScreen(VGLBitmap *object, int x, int y);
1245acf51eaSKazutaka YOKOTA int VGLSetSegment(unsigned int offset);
1259a57b7d2SSøren Schmidt /* mouse.c */
126*c0ce6f7dSBruce Evans int __VGLMouseMode(int mode);
1279a57b7d2SSøren Schmidt void VGLMouseMode(int mode);
1289a57b7d2SSøren Schmidt void VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask);
1299a57b7d2SSøren Schmidt void VGLMouseSetStdImage(void);
1309a57b7d2SSøren Schmidt int VGLMouseInit(int mode);
131e848f3d1SBruce Evans void VGLMouseRestore(void);
1329a57b7d2SSøren Schmidt int VGLMouseStatus(int *x, int *y, char *buttons);
133c7432537SBruce Evans void VGLMouseFreeze(void);
134c7432537SBruce Evans int VGLMouseFreezeXY(int x, int y);
135a07067eaSBruce Evans void VGLMouseMerge(int x, int y, int width, byte *line);
136c7432537SBruce Evans int VGLMouseOverlap(int x, int y, int width, int hight);
1379a57b7d2SSøren Schmidt void VGLMouseUnFreeze(void);
1389a57b7d2SSøren Schmidt /* simple.c */
139933d455fSNicolas Souchu void VGLSetXY(VGLBitmap *object, int x, int y, u_long color);
140933d455fSNicolas Souchu u_long VGLGetXY(VGLBitmap *object, int x, int y);
141933d455fSNicolas Souchu void VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
142933d455fSNicolas Souchu void VGLBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
143933d455fSNicolas Souchu void VGLFilledBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
144933d455fSNicolas Souchu void VGLEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color);
145933d455fSNicolas Souchu void VGLFilledEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color);
146933d455fSNicolas Souchu void VGLClear(VGLBitmap *object, u_long color);
147a93ca07aSBruce Evans u_long VGLrgb332ToNative(byte c);
148e848f3d1SBruce Evans void VGLRestoreBlank(void);
149e848f3d1SBruce Evans void VGLRestoreBorder(void);
1509a57b7d2SSøren Schmidt void VGLRestorePalette(void);
1519a57b7d2SSøren Schmidt void VGLSavePalette(void);
1529a57b7d2SSøren Schmidt void VGLSetPalette(byte *red, byte *green, byte *blue);
1539a57b7d2SSøren Schmidt void VGLSetPaletteIndex(byte color, byte red, byte green, byte blue);
15431d09534SBruce Evans void VGLSetBorder(byte color);
1559a57b7d2SSøren Schmidt void VGLBlankDisplay(int blank);
1569a57b7d2SSøren Schmidt /* text.c */
1579a57b7d2SSøren Schmidt int VGLTextSetFontFile(char *filename);
158dd31deb8SBruce Evans void VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch, u_long fgcol, u_long bgcol, int fill, int dir);
159dd31deb8SBruce Evans void VGLBitmapString(VGLBitmap *Object, int x, int y, char *str, u_long fgcol, u_long bgcol, int fill, int dir);
1600e2fa3bbSMaxim Sobolev 
1610e2fa3bbSMaxim Sobolev #endif /* !_VGL_H_ */
162