Annotation of sbbs/src/conio/ciolib.h, revision 1.1.1.2

1.1.1.2 ! root        1: /* $Id: ciolib.h,v 1.55 2009/02/12 07:19:36 deuce Exp $ */
1.1       root        2: 
                      3: /****************************************************************************
                      4:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      5:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                      6:  *                                                                                                                                                     *
                      7:  * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html         *
                      8:  *                                                                                                                                                     *
                      9:  * This library is free software; you can redistribute it and/or                       *
                     10:  * modify it under the terms of the GNU Lesser General Public License          *
                     11:  * as published by the Free Software Foundation; either version 2                      *
                     12:  * of the License, or (at your option) any later version.                                      *
                     13:  * See the GNU Lesser General Public License for more details: lgpl.txt or     *
                     14:  * http://www.fsf.org/copyleft/lesser.html                                                                     *
                     15:  *                                                                                                                                                     *
                     16:  * Anonymous FTP access to the most recent released source is available at     *
                     17:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     18:  *                                                                                                                                                     *
                     19:  * Anonymous CVS access to the development source and modification history     *
                     20:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     21:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     22:  *     (just hit return, no password is necessary)                                                     *
                     23:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     24:  *                                                                                                                                                     *
                     25:  * For Synchronet coding style and modification guidelines, see                                *
                     26:  * http://www.synchro.net/source.html                                                                          *
                     27:  *                                                                                                                                                     *
                     28:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     29:  * format) via e-mail to [email protected]                                                                      *
                     30:  *                                                                                                                                                     *
                     31:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     32:  ****************************************************************************/
                     33: 
                     34: #ifndef _CIOLIB_H_
                     35: #define _CIOLIB_H_
                     36: 
                     37: #include <string.h>    /* size_t */
                     38: #include "mouse.h"
                     39: 
                     40: #ifdef CIOLIBEXPORT
                     41:         #undef CIOLIBEXPORT
                     42: #endif
                     43: 
                     44: #ifdef _WIN32
                     45:         #ifdef __BORLANDC__
                     46:                 #define CIOLIBCALL __stdcall
                     47:         #else
                     48:                 #define CIOLIBCALL
                     49:         #endif
                     50:         #if defined(CIOLIB_IMPORTS) || defined(CIOLIB_EXPORTS)
                     51:                 #if defined(CIOLIB_IMPORTS)
                     52:                         #define CIOLIBEXPORT __declspec( dllimport )
                     53:                         #define CIOLIBEXPORTVAR __declspec( dllimport )
                     54:                 #else
                     55:                         #define CIOLIBEXPORT __declspec( dllexport )
                     56:                         #define CIOLIBEXPORTVAR __declspec( dllexport )
                     57:                 #endif
                     58:         #else   /* self-contained executable */
                     59:                 #define CIOLIBEXPORT
                     60:                 #define CIOLIBEXPORTVAR        extern
                     61:         #endif
                     62: #elif defined __unix__
                     63:         #define CIOLIBCALL
                     64:         #define CIOLIBEXPORT
                     65:         #define CIOLIBEXPORTVAR        extern
                     66: #else
                     67:         #define CIOLIBCALL
                     68:         #define CIOLIBEXPORT
                     69:         #define CIOLIBEXPORTVAR        extern
                     70: #endif
                     71: 
                     72: enum {
                     73:         CIOLIB_MODE_AUTO
                     74:        ,CIOLIB_MODE_CURSES
                     75:        ,CIOLIB_MODE_CURSES_IBM
                     76:        ,CIOLIB_MODE_ANSI
                     77:        ,CIOLIB_MODE_X
                     78:        ,CIOLIB_MODE_CONIO
1.1.1.2 ! root       79:        ,CIOLIB_MODE_CONIO_FULLSCREEN
1.1       root       80:        ,CIOLIB_MODE_SDL
                     81:        ,CIOLIB_MODE_SDL_FULLSCREEN
1.1.1.2 ! root       82:        ,CIOLIB_MODE_SDL_YUV
        !            83:        ,CIOLIB_MODE_SDL_YUV_FULLSCREEN
1.1       root       84: };
                     85: 
                     86: #if defined(_WIN32)    /* presumably, Win32 */
                     87: 
                     88:        #include <io.h>                 /* isatty */
                     89: 
                     90: #endif
                     91: 
                     92: #ifndef __COLORS
                     93: #define __COLORS
                     94: 
                     95: enum {
                     96:         BLACK
                     97:        ,BLUE
                     98:        ,GREEN
                     99:        ,CYAN
                    100:        ,RED
                    101:        ,MAGENTA
                    102:        ,BROWN  
                    103:        ,LIGHTGRAY      
                    104:        ,DARKGRAY
                    105:        ,LIGHTBLUE      
                    106:        ,LIGHTGREEN     
                    107:        ,LIGHTCYAN
                    108:        ,LIGHTRED
                    109:        ,LIGHTMAGENTA
                    110:        ,YELLOW
                    111:        ,WHITE
                    112: };
                    113: 
                    114: #endif /* __COLORS */
                    115: 
                    116: #ifndef BLINK
                    117: #define BLINK 128
                    118: #endif
                    119: 
1.1.1.2 ! root      120: #define CIOLIB_VIDEO_ALTCHARS  (1<<0)  // Attribute bit 3 selects alternate char set
        !           121: #define CIOLIB_VIDEO_NOBRIGHT  (1<<1)  // Attribute bit 3 does not increase intensity
        !           122: #define CIOLIB_VIDEO_BGBRIGHT  (1<<2)  // Attribute bit 7 selects high intensity background, not blink
        !           123: 
1.1       root      124: enum text_modes
                    125: {
                    126:     /* DOS-compatible modes */
                    127: 
                    128:     LASTMODE = -1,
                    129:     BW40     = 0,
                    130:     C40,
                    131:     BW80,
                    132:     C80,
                    133:     MONO     = 7,
                    134: 
                    135:     /* New Color modes */
                    136: 
                    137:     C40X14   = 8,
                    138:     C40X21,
                    139:     C40X28,
                    140:     C40X43,
                    141:     C40X50,
                    142:     C40X60,
                    143: 
                    144:     C80X14,
                    145:     C80X21,
                    146:     C80X28,
                    147:     C80X43,
                    148:     C80X50,
                    149:     C80X60,
                    150: 
                    151:     /* New Black & White modes */
                    152: 
                    153:     BW40X14,
                    154:     BW40X21,
                    155:     BW40X28,
                    156:     BW40X43,
                    157:     BW40X50,
                    158:     BW40X60,
                    159: 
                    160:     BW80X14,
                    161:     BW80X21,
                    162:     BW80X28,
                    163:     BW80X43,
                    164:     BW80X50,
                    165:     BW80X60,
                    166: 
                    167:     /* New Monochrome modes */
                    168: 
                    169:     MONO14,             /* Invalid VGA mode */
                    170:     MONO21,
                    171:     MONO28,
                    172:     MONO43,
                    173:     MONO50,
                    174:     MONO60,
                    175: 
                    176:     C4350    = C80X50, /* this is actually "64" in the "real" conio */
                    177: 
1.1.1.2 ! root      178:     _ORIGMODE = 65,      /* original mode at program startup */
        !           179: 
        !           180:     C64_40X25 = 147,   /* Commodore 64 40x25 colour mode */
        !           181:     C128_40X25,                /* Commodore 128 40x25 colour mode */
        !           182:     C128_80X25,                /* Commodore 128 40x25 colour mode */
        !           183:        ATARI_40X24,    /* Atari 800 40x24 colour text mode */
        !           184:        ATARI_80X25,    /* Atari 800 XEP80 80x25 mono text mode */
        !           185: 
        !           186:        /* VESA Modes */
        !           187:        VESA_132X21     = 235,
        !           188:        VESA_132X25     = 231,
        !           189:        VESA_132X28     = 228,
        !           190:        VESA_132X30     = 226,
        !           191:        VESA_132X34     = 222,
        !           192:        VESA_132X43     = 213,
        !           193:        VESA_132X50     = 206,
        !           194:        VESA_132X60     = 196,
1.1       root      195: };
                    196: 
                    197: #define COLOR_MODE     C80
                    198: 
                    199: enum
                    200: {
                    201:        _NOCURSOR,
                    202:        _SOLIDCURSOR,
                    203:        _NORMALCURSOR
                    204: };
                    205: 
                    206: struct text_info {
                    207:        unsigned char winleft;        /* left window coordinate */
                    208:        unsigned char wintop;         /* top window coordinate */
                    209:        unsigned char winright;       /* right window coordinate */
                    210:        unsigned char winbottom;      /* bottom window coordinate */
                    211:        unsigned char attribute;      /* text attribute */
                    212:        unsigned char normattr;       /* normal attribute */
                    213:        unsigned char currmode;       /* current video mode:
                    214:                                         BW40, BW80, C40, C80, or C4350 */
                    215:        unsigned char screenheight;   /* text screen's height */
                    216:        unsigned char screenwidth;    /* text screen's width */
                    217:        unsigned char curx;           /* x-coordinate in current window */
                    218:        unsigned char cury;           /* y-coordinate in current window */
                    219: };
                    220: 
1.1.1.2 ! root      221: extern struct text_info cio_textinfo;
        !           222: 
1.1       root      223: typedef struct {
                    224:        int             mode;
                    225:        int             mouse;
                    226:        void    (*clreol)               (void);
                    227:        int             (*puttext)              (int,int,int,int,void *);
                    228:        int             (*gettext)              (int,int,int,int,void *);
                    229:        void    (*textattr)             (int);
                    230:        int             (*kbhit)                (void);
                    231:        void    (*delay)                (long);
                    232:        int             (*wherex)               (void);
                    233:        int             (*wherey)               (void);
                    234:        int             (*putch)                (int);
                    235:        void    (*gotoxy)               (int,int);
                    236:        void    (*clrscr)               (void);
                    237:        void    (*gettextinfo)  (struct text_info *);
                    238:        void    (*setcursortype)(int);
                    239:        int             (*getch)                (void);
                    240:        int             (*getche)               (void);
                    241:        int             (*beep)                 (void);
                    242:        void    (*highvideo)    (void);
                    243:        void    (*lowvideo)             (void);
                    244:        void    (*normvideo)    (void);
                    245:        void    (*textmode)             (int);
                    246:        int             (*ungetch)              (int);
                    247:        int             (*movetext)             (int,int,int,int,int,int);
                    248:        char    *(*cgets)               (char *);
                    249:        int             (*cscanf)               (char *,...);
                    250:        char    *(*getpass)             (const char *);
                    251:        void    (*wscroll)              (void);
                    252:        void    (*window)               (int,int,int,int);
                    253:        void    (*delline)              (void);
                    254:        void    (*insline)              (void);
                    255:        int             (*cprintf)              (char *,...);
                    256:        int             (*cputs)                (char *);
                    257:        void    (*textbackground)       (int);
                    258:        void    (*textcolor)    (int);
                    259:        int             (*getmouse)             (struct mouse_event *mevent);
                    260:        int             (*ungetmouse)   (struct mouse_event *mevent);
                    261:        int             (*hidemouse)    (void);
                    262:        int             (*showmouse)    (void);
                    263:        void    (*settitle)             (const char *);
                    264:        void    (*setname)              (const char *);
1.1.1.2 ! root      265:        void    (*seticon)              (const void *, unsigned long);
1.1       root      266:        void    (*copytext)             (const char *, size_t);
                    267:        char    *(*getcliptext) (void);
                    268:        void    (*suspend)              (void);
                    269:        void    (*resume)               (void);
1.1.1.2 ! root      270:        int             (*setfont)              (int font, int force, int font_num);
1.1       root      271:        int             (*getfont)              (void);
                    272:        int             (*loadfont)             (char *filename);
1.1.1.2 ! root      273:        int             (*get_window_info)              (int* width, int* height, int* xpos, int* ypos);
        !           274:        void    (*getcustomcursor)      (int *startline, int *endline, int *range, int *blink, int *visible);
        !           275:        void    (*setcustomcursor)      (int startline, int endline, int range, int blink, int visible);
        !           276:        void    (*setvideoflags)        (int flags);
        !           277:        int             (*getvideoflags)        (void);
1.1       root      278:        int             *ESCDELAY;
                    279: } cioapi_t;
                    280: 
                    281: CIOLIBEXPORTVAR cioapi_t cio_api;
                    282: CIOLIBEXPORTVAR int _wscroll;
                    283: CIOLIBEXPORTVAR int directvideo;
                    284: CIOLIBEXPORTVAR int hold_update;
                    285: CIOLIBEXPORTVAR int puttext_can_move;
                    286: 
                    287: #define _conio_kbhit()         kbhit()
                    288: 
                    289: #ifdef __cplusplus
                    290: extern "C" {
                    291: #endif
                    292: CIOLIBEXPORT int CIOLIBCALL initciolib(int mode);
                    293: CIOLIBEXPORT void CIOLIBCALL suspendciolib(void);
                    294: 
                    295: CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
                    296: CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str);
                    297: CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...);
                    298: CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void);
                    299: CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void);
                    300: CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void);
                    301: CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch);
                    302: CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info);
                    303: CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void);
                    304: CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void);
                    305: CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void);
                    306: CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y);
                    307: CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void);
                    308: CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void);
                    309: CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str);
                    310: CIOLIBEXPORT int       CIOLIBCALL ciolib_cprintf(char *fmat, ...);
                    311: CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour);
                    312: CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour);
                    313: CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void);
                    314: CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void);
                    315: CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void);
                    316: CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
                    317: CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
                    318: CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a);
                    319: CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a);
                    320: CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a);
                    321: CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a);
                    322: CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode);
                    323: CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey);
                    324: CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void);
                    325: CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void);
                    326: CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt);
                    327: CIOLIBEXPORT void CIOLIBCALL ciolib_settitle(const char *title);
                    328: CIOLIBEXPORT void CIOLIBCALL ciolib_setname(const char *title);
1.1.1.2 ! root      329: CIOLIBEXPORT void CIOLIBCALL ciolib_seticon(const void *icon,unsigned long size);
1.1       root      330: CIOLIBEXPORT int CIOLIBCALL ciolib_showmouse(void);
                    331: CIOLIBEXPORT int CIOLIBCALL ciolib_hidemouse(void);
                    332: CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen);
                    333: CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void);
1.1.1.2 ! root      334: CIOLIBEXPORT int CIOLIBCALL ciolib_setfont(int font, int force, int font_num);
1.1       root      335: CIOLIBEXPORT int CIOLIBCALL ciolib_getfont(void);
                    336: CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename);
1.1.1.2 ! root      337: CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos);
        !           338: CIOLIBEXPORT int CIOLIBCALL ciolib_beep(void);
        !           339: CIOLIBEXPORT void CIOLIBCALL ciolib_getcustomcursor(int *startline, int *endline, int *range, int *blink, int *visible);
        !           340: CIOLIBEXPORT void CIOLIBCALL ciolib_setcustomcursor(int startline, int endline, int range, int blink, int visible);
        !           341: CIOLIBEXPORT void CIOLIBCALL ciolib_setvideoflags(int flags);
        !           342: CIOLIBEXPORT int CIOLIBCALL ciolib_getvideoflags(void);
        !           343: 
        !           344: /* DoorWay specific stuff that's only applicable to ANSI mode. */
        !           345: CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
1.1       root      346: #ifdef __cplusplus
                    347: }
                    348: #endif
                    349: 
                    350: #ifndef CIOLIB_NO_MACROS
                    351:        #define cscanf                                  ciolib_cscanf
                    352:        #define cprintf                                 ciolib_cprintf
                    353: 
                    354:        #define movetext(a,b,c,d,e,f)   ciolib_movetext(a,b,c,d,e,f)
                    355:        #define cgets(a)                                ciolib_cgets(a)
                    356:        #define kbhit()                                 ciolib_kbhit()
                    357:        #define getch()                                 ciolib_getch()
                    358:        #define getche()                                ciolib_getche()
                    359:        #define ungetch(a)                              ciolib_ungetch(a)
                    360:        #define gettextinfo(a)                  ciolib_gettextinfo(a)
                    361:        #define wherex()                                ciolib_wherex()
                    362:        #define wherey()                                ciolib_wherey()
                    363:        #define wscroll()                               ciolib_wscroll()
                    364:        #define gotoxy(a,b)                             ciolib_gotoxy(a,b)
                    365:        #define clreol()                                ciolib_clreol()
                    366:        #define clrscr()                                ciolib_clrscr()
                    367:        #define cputs(a)                                ciolib_cputs(a)
                    368:        #define textbackground(a)               ciolib_textbackground(a)
                    369:        #define textcolor(a)                    ciolib_textcolor(a)
                    370:        #define highvideo()                             ciolib_highvideo()
                    371:        #define lowvideo()                              ciolib_lowvideo()
                    372:        #define normvideo()                             ciolib_normvideo()
                    373:        #define puttext(a,b,c,d,e)              ciolib_puttext(a,b,c,d,e)
                    374:        #define gettext(a,b,c,d,e)              ciolib_gettext(a,b,c,d,e)
                    375:        #define textattr(a)                             ciolib_textattr(a)
                    376:        #define delay(a)                                ciolib_delay(a)
                    377:        #define putch(a)                                ciolib_putch(a)
                    378:        #define _setcursortype(a)               ciolib_setcursortype(a)
                    379:        #define textmode(a)                             ciolib_textmode(a)
                    380:        #define window(a,b,c,d)                 ciolib_window(a,b,c,d)
                    381:        #define delline()                               ciolib_delline()
                    382:        #define insline()                               ciolib_insline()
                    383:        #define getpass(a)                              ciolib_getpass(a)
                    384:        #define getmouse(a)                             ciolib_getmouse(a)
                    385:        #define ungetmouse(a)                   ciolib_ungetmouse(a)
                    386:        #define hidemouse()                             ciolib_hidemouse()
                    387:        #define showmouse()                             ciolib_showmouse()
                    388:        #define setname(a)                              ciolib_setname(a)
1.1.1.2 ! root      389:        #define seticon(a,b)                    ciolib_seticon(a,b)
1.1       root      390:        #define settitle(a)                             ciolib_settitle(a)
                    391:        #define copytext(a,b)                   ciolib_copytext(a,b)
                    392:        #define getcliptext()                   ciolib_getcliptext()
1.1.1.2 ! root      393:        #define setfont(a,b,c)                  ciolib_setfont(a,b,c)
1.1       root      394:        #define getfont()                               ciolib_getfont()
                    395:        #define loadfont(a)                             ciolib_loadfont(a)
1.1.1.2 ! root      396:        #define get_window_info(a,b,c,d)        ciolib_get_window_info(a,b,c,d)
        !           397:        #define beep()                          ciolib_beep()
        !           398:        #define getcustomcursor(a,b,c,d,e)      ciolib_getcustomcursor(a,b,c,d,e)
        !           399:        #define setcustomcursor(a,b,c,d,e)      ciolib_setcustomcursor(a,b,c,d,e)
        !           400:        #define setvideoflags(a)                ciolib_setvideoflags(a)
        !           401:        #define getvideoflags()                 ciolib_getvideoflags()
        !           402: #endif
        !           403: 
        !           404: #ifdef WITH_SDL
        !           405:        #include <SDL.h>
        !           406: 
        !           407:        #ifdef main
        !           408:                #undef main
        !           409:        #endif
        !           410:        #define main    CIOLIB_main
1.1       root      411: #endif
                    412: 
                    413: #endif /* Do not add anything after this line */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.