| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | VidMgr 1 of 4 |
* Crossposted in area ED_CODE, AUST_C_HERE, C_ECHO, PUBLIC_DOMAIN
>>>>>>>>>> CSplit: Version 2.1
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin part 1/4
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin file VIDMGR.H
>>>>>>>>>>
/*
* vidmgr.h. Written by Andrew Clarke and released to the public domain.
*
* Screen drawing, cursor and keyboard routines for text mode DOS and
* OS/2 applications.
*
* Compiled and tested (a bit ) using:
*
* - Borland C++ for DOS 3.1
* - Microsoft QuickC for DOS 2.5 (should also work with MSC 6.0)
* - WATCOM C/C++ (16-bit and 32-bit) for DOS 10.0
* - Borland C++ for OS/2 1.0
* - WATCOM C/C++ (32-bit) for OS/2 10.0
* - emx 0.9a/gcc 2.7.2 for OS/2
*/
#ifndef __VIDMGR_H__
#define __VIDMGR_H__
#if defined(_QC) || defined(__DOS__)
#define __MSDOS__
#endif
#if defined(__EMX__)
#define __OS2__
#endif
#define BLACK 0x00
#define BLUE 0x01
#define GREEN 0x02
#define CYAN 0x03
#define RED 0x04
#define MAGENTA 0x05
#define PURPLE 0x05
#define BROWN 0x06
#define LIGHTGRAY 0x07
#define LIGHTGREY 0x07
#define DARKGRAY 0x08
#define DARKGREY 0x08
#define LIGHTBLUE 0x09
#define LIGHTGREEN 0x0a
#define LIGHTCYAN 0x0b
#define LIGHTRED 0x0c
#define LIGHTMAGENTA 0x0d
#define LIGHTPURPLE 0x0d
#define YELLOW 0x0e
#define WHITE 0x0f
#define BLINK 0x80
#define CURSOR_HIDE 0
#define CURSOR_NORM 1
#define CURSOR_HALF 2
#define CURSOR_FULL 3
#define vm_color(fore, back) ((fore) | (back << 4))
struct vm_info {
char attr; /* text attribute */
#if defined(__MSDOS__)
char mode; /* video mode */
#endif
char height; /* screen height */
char width; /* screen width */
char ypos; /* y-coordinate */
char xpos; /* x-coordinate */
char cur_start; /* cursor start line */
char cur_end; /* cursor end line */
};
extern struct vm_info vm_startup;
extern char vm_curattr;
extern char vm_frame_blank[];
extern char vm_frame_single[];
extern char vm_frame_double[];
char vm_getscreenwidth(void);
char vm_getscreenheight(void);
short vm_getscreensize(void);
#if defined(__MSDOS__)
int vm_iscolorscreen(void);
char FAR *vm_screenptr(char x, char y);
char vm_getscreenmode(void);
void vm_setscreenmode(char mode);
#endif
void vm_paintclearbox(char x1, char y1, char x2, char y2, char attr);
void vm_paintclearscreen(char attr);
void vm_paintclearline(char row, char attr);
void vm_paintbox(char x1, char y1, char x2, char y2, char attr);
void vm_paintscreen(char attr);
void vm_paintline(char row, char attr);
void vm_clearbox(char x1, char y1, char x2, char y2);
void vm_clearscreen(void);
void vm_clearline(char row);
void vm_clrscr(void);
void vm_gotoxy(char x, char y);
char vm_wherex(void);
char vm_wherey(void);
char vm_getchxy(char x, char y);
char vm_getattrxy(char x, char y);
void vm_xgetchxy(char x, char y, char *attr, char *ch);
void vm_setattr(char attr);
void vm_putattr(char x, char y, char attr);
void vm_attrib(char x1, char y1, char x2, char y2, char attr);
void vm_setcursorsize(char start, char end);
void vm_getcursorsize(char *start, char *end);
void vm_setcursorstyle(int style);
void vm_putch(char x, char y, char ch);
void vm_puts(char x, char y, char *str);
void vm_printf(char x, char y, const char *format, ...);
void vm_printfcenter(char row, const char *format, ...);
void vm_printfbetween(char x1, char x2, char row, const char *format, \
\
...);
void vm_xputch(char x, char y, char attr, char ch);
void vm_xputs(char x, char y, char attr, char *str);
void vm_xprintf(char x, char y, char attr, const char *format, ...);
void vm_xprintfcenter(char row, char attr, const char *format, ...);
void vm_xprintfbetween(char x1, char x2, char row, char attr, const \
\
char *format, ...);
int vm_kbhit(void);
int vm_getch(void);
void vm_horizline(char x1, char x2, char row, char attr, char ch);
void vm_vertline(char y1, char y2, char col, char attr, char ch);
void vm_frame(char x1, char y1, char x2, char y2, char attr, char \
\
*frame);
void vm_gettext(char x1, char y1, char x2, char y2, char *dest);
void vm_puttext(char x1, char y1, char x2, char y2, char *srce);
void vm_getinfo(struct vm_info *v);
void vm_init(void);
void vm_done(void);
#endif /* __VIDMGR_H__ */
>>>>>>>>>> CSplit: End file VIDMGR.H
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin file VIDMGR.C
>>>>>>>>>>
/*
* vidmgr.c. Written by Andrew Clarke and released to the public domain.
*
* Screen drawing, cursor and keyboard routines for text mode DOS and
* OS/2 applications.
*
* Compiled and tested (a bit ) using:
*
* - Borland C++ for DOS 3.1
* - Microsoft QuickC for DOS 2.5 (should also work with MSC 6.0)
* - WATCOM C/C++ (16-bit and 32-bit) for DOS 10.0
* - Borland C++ for OS/2 1.0
* - WATCOM C/C++ (32-bit) for OS/2 10.0
* - emx 0.9a/gcc 2.7.2 for OS/2
*/
#include
#include
#include
#include
#include
#if defined(__WATCOMC__)
#include
#endif
#include "extkword.h"
#include "vidmgr.h"
struct vm_info vm_startup;
char vm_curattr;
char vm_frame_blank[] = " ";
char vm_frame_single[] = "ÚÄ¿³ÀÙ";
char vm_frame_double[] = "ÉÍ»ºÈ¼";
void vm_setattr(char attr)
{
vm_curattr = attr;
}
void vm_printf(char x, char y, const char *format,...)
{
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
vm_puts(x, y, buffer);
}
void vm_printfcenter(char row, const char *format,...)
{
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
vm_puts((char) ((vm_getscreenwidth() / 2) - (strlen(buffer) / 2)), \
\
row, buffer);
}
void vm_printfbetween(char x1, char x2, char row, const char *format,...)
{
char x;
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
if ((char) strlen(buffer) >= (char) (x2 - x1 + 1)) {
vm_puts(x1, row, buffer);
} else {
x = (char) (x1 + (x2 - x1 + 1 - strlen(buffer)) / 2);
vm_puts(x, row, buffer);
}
}
void vm_xprintf(char x, char y, char attr, const char *format,...)
{
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
vm_xputs(x, y, attr, buffer);
}
void vm_xprintfcenter(char row, char attr, const char *format,...)
{
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
vm_xputs((char) ((vm_getscreenwidth() / 2) - (strlen(buffer) / 2)), \
\
row, attr, buffer);
}
void vm_xprintfbetween(char x1, char x2, char row, char attr, const \
\
char *format,...)
{
char x;
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
if ((char) strlen(buffer) >= (char) (x2 - x1 + 1)) {
vm_xputs(x1, row, attr, buffer);
} else {
x = (char) (x1 + (x2 - x1 + 1 - strlen(buffer)) / 2);
vm_xputs(x, row, attr, buffer);
}
}
void vm_getinfo(struct vm_info *v)
{
v->ypos = vm_wherey();
v->xpos = vm_wherex();
v->attr = vm_getattrxy(v->xpos, v->ypos);
#if defined(__MSDOS__)
v->mode = vm_getscreenmode();
#endif
v->height = vm_getscreenheight();
v->width = vm_getscreenwidth();
vm_getcursorsize(&v->cur_start, &v->cur_end);
}
void vm_init(void)
{
vm_getinfo(&vm_startup);
vm_setattr(vm_startup.attr);
}
void vm_done(void)
{
#if defined(__MSDOS__)
if (vm_getscreenmode() != vm_startup.mode)
vm_setscreenmode(vm_startup.mode);
#endif
vm_setcursorsize(vm_startup.cur_start, vm_startup.cur_end);
}
void vm_paintclearscreen(char attr)
{
vm_paintclearbox(1, 1, vm_getscreenwidth(), vm_getscreenheight(), \
\
attr);
}
void vm_paintclearline(char row, char attr)
{
vm_paintclearbox(1, row, vm_getscreenwidth(), row, attr);
}
void vm_paintscreen(char attr)
{
vm_paintbox(1, 1, vm_getscreenwidth(), vm_getscreenheight(), attr);
}
void vm_paintline(char row, char attr)
{
vm_paintbox(1, row, vm_getscreenwidth(), row, attr);
}
void vm_clearscreen(void)
{
vm_clearbox(1, 1, vm_getscreenwidth(), vm_getscreenheight());
}
void vm_clearline(char row)
{
vm_clearbox(1, row, vm_getscreenwidth(), row);
}
void vm_clrscr(void)
{
vm_paintclearscreen(vm_curattr);
vm_gotoxy(1, 1);
}
void vm_vertline(char y1, char y2, char col, char attr, char ch)
{
char y;
for (y = y1; y <= y2; y++)
vm_xputch(col, y, attr, ch);
}
void vm_frame(char x1, char y1, char x2, char y2, char attr, char *frame)
{
vm_xputch(x1, y1, attr, frame[0]);
vm_horizline((char) (x1 + 1), (char) (x2 - 1), y1, attr, frame[1]);
vm_xputch(x2, y1, attr, frame[2]);
vm_vertline((char) (y1 + 1), (char) (y2 - 1), x1, attr, frame[3]);
vm_vertline((char) (y1 + 1), (char) (y2 - 1), x2, attr, frame[3]);
vm_xputch(x1, y2, attr, frame[4]);
vm_horizline((char) (x1 + 1), (char) (x2 - 1), y2, attr, frame[1]);
vm_xputch(x2, y2, attr, frame[5]);
}
#if defined(__MSDOS__)
#include "mk_fp.h"
int vm_iscolorscreen(void)
{
return vm_getscreenmode() != 7;
}
char vm_getscreenmode(void)
{
>>>>>>>>>> CSplit: End part 1/4 crc: 8c61
>>>>>>>>>>
--- Msgedsq/2 3.30
* Origin: Blizzard of Ozz, Melbourne, Australia (3:635/727.4{at}fidonet)SEEN-BY: 50/99 78/0 620/243 623/630 632/349 634/395 635/503 544 727 711/401 SEEN-BY: 711/409 410 413 430 510 808 809 932 934 712/515 713/888 714/906 SEEN-BY: 800/1 7877/2809 @PATH: 635/727 544 50/99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.