/* =============================== CWINDOWS.H ============================= */ /* Copyright Magna Carta Software 1987, 1988. All Rights Reserved. */ /* Header file for C WINDOWS TOOLKIT v2.0 */ /* COMPATIBILITY: BORLAND TURBOC v1.0+; MICROSOFT C v5.0+/QUICK C v1.0+ */ /* MIX POWER C v1.1+. */ /* Last update: 02-14-89. */ /* ======================================================================== */ /* THIS CODE PREVENTS INCLUSION OF THIS FILE TWICE */ #if !defined(CWINDOWS_H_INCLUDED) /* THIS CODE TURNS OFF THE POWER C LIST OPTION FOR THE DURATION OF THIS FILE */ #if defined(__POWERC) #pragma list- #endif /* THIS CODE DETECTS MSC AND QUICK C */ #if !defined(__POWERC) && !defined(__TURBOC__) && !defined(MSC) #if defined(M_I86) #define MSC #endif #endif /* WE HAVE TO INCLUDE STDIO.H */ #if !defined(NULL) #include #endif /* THESE TWO FILES ARE INCLUDED WITH C WINDOWS TOOLKIT THEY SHOULD BE IN THE "INCLUDE" DIRECTORY AT COMPILE TIME */ #include "keys.h" #include "ascii.h" /* PREFIXES: S -- screen VS -- virtual screen W -- window E -- editor optional; B -- buffer the part of the window that contains data; F -- field optional; U -- user a user-defined function; */ /* NEW TYPES */ #if !defined(TELECOMM_H_INCLUDED) typedef unsigned char BYTE; #endif typedef char *MENU_TEXT[]; typedef struct colors { BYTE fc; /* foreground_color */ BYTE bc; /* background_color */ BYTE hchfc; /* highlight character foreground color */ BYTE bfc; /* bar foreground color */ BYTE bbc; /* bar background color */ BYTE icfc; /* invalid choice_foreground_color */ BYTE icbc; /* invalid_choice_background_color */ } COLORS; typedef struct border { BYTE fc; /* border foreground color */ BYTE bc; /* border background color */ BYTE hch; /* border horizontal character */ BYTE vch; /* border vertical character */ } BORDER; typedef struct shadow { int type; /* if a shadow, values 1-4 tell type. */ BYTE color; /* shadow color */ BYTE ch; /* shadow character */ } SHADOW; typedef struct menu_keys { int topkey; /* key that moves highlight to top */ int bottomkey; /* key that moves highlight to bottom */ int upkey; /* key that moves highlight up one item */ int downkey; /* key that moves highlight down */ int selectkey; /* key that selects the highlighted item */ int esckey; /* key that makes menu disappear */ int pgupkey; /* key to page up */ int pgdnkey; /* key to page down */ int user_key1; /* user defined routine u_popup1(WINDOW *w, int keyinfo); */ int user_key2; /* user defined routine u_popup2(WINDOW *w, int keyinfo); */ int left_key; /* key that moves cursor left */ int right_key; /* key that moves cursor right */ int bol_key; /* key that moves cursor to beginning of line */ int eol_key; /* key that moves cursor to end of line */ int nw_key; /* key that moves cursor to next word */ int pw_key; /* key that moves cursor to previous word */ int delete_key; /* key that deletes a char. in the editor */ } MENU_KEYS; /* MODES FOR CARRIAGE RETURNS AND NEW LINES IN w_putc() AND w_puts() */ #define NOXLAT 0 /* raw mode */ #define CR2LF 1 /* translate CR to LF */ #define CR2CRLF 2 /* convert CR to CRLF */ #define CRLF2LF 3 /* convert CRLF to LF */ #define CRLF2CR 4 /* convert CR to CR */ #define LF2CR 5 /* translate LF to CR */ #define LF2CRLF 6 /* convert LF to CRLF */ #define EOL2SPACE 7 /* translate CR&LF to spaces */ #define STRIPEOL 8 /* remove all CR and LF */ /* FORMAT PARAMETERS IN w_putc(), vs_putc(), w_puts() and vs_puts() */ #define RAWMODE 1 /* print characters as they are */ #define TABSIZE 2 /* tab size (in screen columns) */ #define EOLMODE 3 /* CR/LF conversion */ #define NODELETE 5 #define CASE 15 /* case conversion */ #define UPPER 21 #define LOWER 22 #define MIXED 3 #define CNTRL 7 /* toggle control character acceptability */ /* HOW TO DISPLAY TEXT OUTPUT WITH w_putc() AND w_puts() */ typedef struct format { int f_raw; /* just print raw characters */ int tabsize; /* expand tabs to this size */ int f_eol; /* how to treat carriage returns */ int bspace; /* how to treat backspaces */ int case_use; /* convert to UPPER, lower or none? */ int cntrls[33]; /* acceptable control characters */ } FORMAT; typedef struct popup_menu { COLORS *p_colors; /* ptr. to the colors */ BORDER *p_border; /* ptr. to the border */ SHADOW *p_shadow; /* ptr. to the shadow */ MENU_KEYS *p_keys; /* menu key definitions */ /* TITLE FEATURES */ BYTE tfc; /* title foreground color */ BYTE tbc; /* title background color */ unsigned tcol; /* title column position on first line */ char * title; /* ptr to the title string */ /* GENERAL FEATURES */ BYTE bch; /* background character */ MENU_TEXT * text; /* pointer to the menu text */ unsigned max_item; /* # of last item (0,...,n) */ unsigned nod; /* no. of items (rows) displayed (1,...,n) */ int (*hchar)[]; /* ptr. to an array of highlight addrs. */ } POPUP; /* MANIFEST CONSTANTS FOR POPUP MENU AND FIELD PARAMETERS */ #define FOREGROUND_COLOR 1 #define BACKGROUND_COLOR 2 #define HIGHLIGHT_CHAR_COLOR 3 #define BAR_FOREGROUND_COLOR 4 #define BAR_BACKGROUND_COLOR 5 #define INVALID_FOREGROUND_COLOR 6 #define INVALID_BACKGROUND_COLOR 7 #define BORDER_FOREGROUND_COLOR 8 #define BORDER_BACKGROUND_COLOR 9 #define BORDER_HORIZONTAL_CHAR 10 #define BORDER_VERTICAL_CHAR 11 #define TITLE_FOREGROUND_COLOR 12 #define TITLE_BACKGROUND_COLOR 13 #define TITLE_COLUMN 14 #define SHADOWED 15 #define SHADOW_COLOR 16 #define BACKGROUND_CHAR 17 #define MAX_ITEM 18 #define NUMBER_DISPLAYED 19 #define TOP_KEY 20 #define BOTTOM_KEY 21 #define UP_KEY 22 #define DOWN_KEY 23 #define SELECT_KEY 24 #define ESC_KEY 25 #define PGUP_KEY 26 #define PGDN_KEY 27 #define LEFT_KEY 28 #define RIGHT_KEY 29 #define BOL_KEY 30 #define EOL_KEY 31 #define COLUMN 32 #define ROW 33 #define SECRET 34 #define LENGTH 35 #define WIDTH 1 #define HEIGHT 2 /* INTERRUPT-DRIVEN CLOCK/STOPWATCH/ALARM CLOCK STRUCTURE */ typedef struct tsr_clock { struct wdb *p_win; /* window for display */ char *addr; /* clock address in window buffer */ char far *saddr; /* screeen address of clock */ unsigned w_row; /* window row to display clock */ int att; /* attribute byte */ int display; /* TRUE if clock should be displayed*/ unsigned long alarm_time; /* time until alarm goes off (secs) */ unsigned alarm_armed; /* alarm is set flag */ unsigned alarm_now; /* alarm is tripped flag */ unsigned alarm_active; /* alarm is tripped flag */ unsigned long start_time; /* BIOS time value at start */ #if defined(__TURBOC__) || defined(__POWERC) void interrupt (far *old_int1Ch)(void); #elif defined(MSC) void (interrupt far *old_int1Ch)(void); #endif } CLOCK; /* THE DATA-ENTRY FORM FIELD */ struct field { struct vsdb *pvs; /* virtual screen that contains this field */ int id; /* ID of this field */ unsigned col; unsigned row; int len; /* length of the field */ int ccol; /* cursor column in field */ COLORS *p_colors; /* ptr. to field color information */ int bch; /* background character */ int secret; /* if 0X0, echo char., else echo this char */ int *a_n; /* array of non-printing, non-error, chars. */ int (*p_uerr)(struct field *f, int *scan, int *key); int (*p_uentry)(struct field *f, int *scan, int *key); int (*p_uexit)(struct field *f, int *scan, int *key); char *template; char *text; char *literal; char *frame; struct menu_keys *p_keys; struct field *prev; struct field *next; }; typedef struct field FIELD; #if !defined(WINDOW_DEFINED) /* This is the window format */ typedef struct wdb { char *ptr; /* pointer to the first byte of stored window */ unsigned width; /* width of window (bytes excl. attribute byte) */ unsigned height; /* height of window, screen rows */ int sfcol; /* first column of window on screen */ int sfrow; /* first row of window on screen */ int slcol; /* last column of window on screen */ int slrow; /* last row of window on screen */ int spos; /* start address of window (rel. to screen) */ int priority; /* non-zero if window displayed. */ int id; /* Identification number for this window */ /* BUFFER INFORMATION (i.e. the area inside any shadow and/or border) */ char *p_wbuf; /* pointer to the first byte of window data */ unsigned bw; /* word width of window - shadow and border */ unsigned bh; /* word height of a window - shadow and border */ int inc; /* amount of the increment between buffer rows */ /* excluding the attribute byte */ /* WINDOW CURSOR INFORMATION */ int cursor_col; /* column of cursor rel. to window */ int cursor_row; /* row of cursor rel. to window */ int cursor_top; /* top scan line of window's cursor */ int cursor_bot; /* bottom scan line of window's cursor */ /* SUBSIDIARY STRUCTURES */ COLORS *p_colors; /* ptr. to the COLORS structure for the window */ BORDER *p_border; /* ptr. to the BORDER structure for the window */ SHADOW *p_shadow; /* ptr. to the SHADOW structure for the window */ FORMAT *p_format; /* ptr. to the FORMAT structure for the window */ struct vsdb *p_vs; /* ptr. to the virtual screen for the window */ POPUP *p_popup; /* if a popup menu, this is not null */ BYTE on_page[16];/* counter of video pages window is displayed */ char *fname; /* if stored on disk, this is the file */ } WINDOW; #define WINDOW_DEFINED #endif /* THE VIRTUAL SCREEN DESCRIPTOR BLOCK */ typedef struct vsdb { char huge *p_buf; /* pointer to the first byte of buffer */ unsigned width; /* width of window (bytes excl. attribute byte) */ unsigned height; /* height of window, screen rows */ char huge *vbegin; /* first byte of virtual screen that is visible */ int wfcol; /* column of virtual screen in TL of window */ int wfrow; /* row of virtual screen in TL of window */ int id; /* Identification number for this virtual screen*/ COLORS *p_colors; /* pointer to color information */ WINDOW *p_win; /* address of the window to display within */ FIELD *pf; /* pointer to data field information */ /* VIRTUAL SCREEN CURSOR INFORMATION */ int cursor_col; /* column of cursor */ int cursor_row; /* row of cursor */ int cursor_top; /* top scan line of cursor */ int cursor_bot; /* bottom scan line of cursor */ FORMAT *p_format; /* pointer to text display formatting inf. */ } VSCREEN; /* EDITOR-RELATED DEFINITIONS */ typedef struct ed_line { char *text; /* pointer to the current line */ struct ed_line *next; /* pointer to the next line */ struct ed_line *prev; /* pointer to the previous line */ unsigned len; /* length of a line (bytes) */ unsigned num; /* line number */ } LINE; typedef struct buffer { int hzone; /* length of hyphenation zone */ unsigned ccol; /* cursor column */ unsigned crow; /* cursor row */ unsigned num_lines; /* number of lines in buffer */ unsigned max_lines; /* max lines allowed */ char *fname; /* file name associated with buffer */ unsigned long fsize; /* file size */ FILE *stream; /* handle associated with file */ MENU_KEYS *pk; /* pointer to the keyboard mapping */ LINE *pl; /* pointer to first line of buffer */ LINE *cl; /* pointer to current line of buffer */ LINE *pwb; /* pointer to the wrap buffer */ VSCREEN *pv; /* window in which editor is displayed */ FORMAT *pf; /* format information */ } BUFFER; #define LINELEN 100 /* length of a line */ #define FBLOCKSIZE 512 /* size of file blocks to read */ #define FORWARD 1 #define BACKWARD -1 extern int hzone; /* MISCELLANEOUS DEFINES */ #if defined(__TURBOC__) || defined(MSC) #define EOF (-1) #elif defined(__POWERC) #define EOF -1 #endif #define WBUF 265 /* length of line buffer for screen writing */ #define SOUND_ON (-1.0) #define SOUND_OFF (-2.0) #define HIDE 0 #define DISPLAY 1 #define RUN_TIME 0 #define EMPTY (-1) #define FALSE 0 #define TRUE !FALSE #define ON 1 #define OFF 0 #define SET 1 #define GET 2 #define ABORT 2 /* return from critical error */ #define RETRY 1 /* return from critical error */ #define IGNORE 0 /* return from critical error */ #define FILE_NOT_FOUND 2 /* attempt to delete file */ #define FILE_ACCESS_DENIED 5 /* access to file denied */ #define _KEYBRD_READ 0 #define _KEYBRD_READY 1 #define _KEYBRD_SHIFTSTATUS 2 /* ATTRIBUTES on the IBM PC in textmode */ extern BYTE black; /* 0 */ extern BYTE blue; /* 1 */ extern BYTE green; /* 2 */ extern BYTE cyan; /* 3 */ extern BYTE red; /* 4 */ extern BYTE magenta; /* 5 */ extern BYTE brown; /* 6 */ extern BYTE white; /* 7 */ extern BYTE grey; /* 8 */ extern BYTE lblue; /* 9 */ extern BYTE lgreen; /* 10 */ extern BYTE lcyan; /* 11 */ extern BYTE lred; /* 12 */ extern BYTE lmagenta; /* 13 */ extern BYTE yellow; /* 14 */ extern BYTE lwhite; /* 15 */ extern BYTE bright; /* 8 */ extern BYTE light; /* 8 */ extern BYTE blink; /* 128 */ /* MANIFEST CONSTANTS FOR COLORS */ #if !defined(__COLORS) #define BLACK 0 #define BLUE 1 #define GREEN 2 #define CYAN 3 #define RED 4 #define MAGENTA 5 #define BROWN 6 #define LIGHTGRAY 7 #define DARKGRAY 8 #define LIGHTBLUE 9 #define LIGHTGREEN 10 #define LIGHTCYAN 11 #define LIGHTRED 12 #define LIGHTMAGENTA 13 #define YELLOW 14 #define WHITE 15 #define __COLORS #endif #define LIGHTGREY 7 #define DARKGREY 8 #define BRIGHT 8 #define LIGHT 8 #define LIGHTWHITE 15 #define BRIGHTWHITE 15 #define BLINK 128 #define UNDERLINE 1 /* MONO ONLY -- USE AS FOREGROUND WITH BLACK BGD. */ #define underline 1 /* MONO ONLY -- USE AS FOREGROUND WITH BLACK BGD. */ /* EXPLODING WINDOWS AND (1-4) SHADOW SPECIAL EFFECTS */ #define CENTER (-1) #define center CENTER #define CENTRE CENTER #define centre CENTER #define CURRENT (-1) #define current CURRENT #define SINGLE 's' #define DOUBLE 'd' #define TOP_LEFT 1 #define TOP_RIGHT 2 #define BOTTOM_LEFT 3 #define BOTTOM_RIGHT 4 #define SLIDING_DOORS 5 #define LEFT_TO_RIGHT 6 #define RIGHT_TO_LEFT 7 /* WINDOW MOVEMENT DIRECTIONS */ #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 /* VIDEO MODES USED IN SWITCHING ADAPTERS */ #define MO80 0X30 /* Monochrome Display Adapter Active */ #define CO40 0X10 /* CGA in 40-col mode active */ #define CO80 0X20 /* CGA in 80-col mode active */ #define EGA80 0XCF /* EGA in 80-col mode active */ /* SCREEN LOCATIONS */ #define CGA_BUFFER 0XB8000000L /* starting address of CGA buffer */ #define EGA_BUFFER 0XA0000000L /* starting address of EGA buffer */ #define MONO_BUFFER 0XB0000000L /* starting address of monochrome/hercules buffer */ /* INTERRUPTS */ #define EOI 0X20 #define PIC 0X21 #define KEYBOARD 0X16 /* The BIOS keyboard interrupt */ #define VIDEO 0X10 /* The BIOS video interrupt */ /* SCREEN PARAMETERS */ struct screen_descriptor { unsigned rows; unsigned cols; unsigned regen_len; /* screen regeneration length (bytes) */ BYTE active_page, old_active_page; BYTE write_page, old_write_page; unsigned logical_width; /* screen logical width (bytes max: 0X200) */ unsigned a_start; /* start addr. of screen "A" in split screen mode */ unsigned start_addr; /* screen start addr for smooth scrolling (max: 0x7000) */ unsigned left_edge; unsigned right_edge; }; extern struct screen_descriptor screen; /* VIDEO STATE PARAMETERS (UPDATED DURING EXECUTION) */ struct video_descriptor { int mode; /* current video mode */ unsigned mono; /* TRUE if monochrome monitor attached */ unsigned analog; /* TRUE if analog monitor attached */ unsigned on; /* TRUE if video is on */ unsigned display; /* TRUE if a display is attached */ unsigned blink; /* TRUE if blinking is enabled */ unsigned ev_active; /* if TRUE, an EGA or VGA is active */ unsigned color; /* if TRUE, drives color monitor */ unsigned ecd; /* if TRUE, Enhanced Color Display */ unsigned ram; /* size of EGA/VGA memory (in k) */ int char_ht, char_wi; /* character height and width (text mode) */ int csize; /* size of cursor. (hi << 8) | lo */ char far * base; /* starting address of the video buffer */ char far * w_addr; /* starting address of write video page */ char far * a_addr; /* starting address of active video page */ unsigned end_of_buffer; /* end of video buffer */ int hpel, vpel; /* horizontal and vertical pel position */ unsigned isr; /* EGA/VGA input status register address */ unsigned crtc; /* CRT Controller Register address */ unsigned old_mode; /* saved mode if adapter switched */ int old_adapter; /* saved adapter if switched */ }; extern struct video_descriptor video; /* STRUCTURES THAT PRESERVE THE STARTUP STATE */ struct startup_descriptor { unsigned adapter; /* adapter in use at startup */ unsigned video_mode; unsigned rows; unsigned cols; unsigned crow; /* cursor row */ unsigned ccol; /* cursor column */ BYTE chigh; /* top of cursor (high scan line) */ BYTE clow; /* bottom of cursor (low scan line) */ BYTE active_page; /* visible page */ unsigned regen_len; /* screen regeneration length (bytes) */ }; extern struct startup_descriptor startup; /* MDA-SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ #define CRT_INDEX_REG_MONO 0X03B4 /* 6845 Index Register */ #define CRT_DATA_REG_MONO 0X03B5 /* 6845 Data Register */ #define CRT_DMC_REG_MONO 0X03B8 /* 6845 Display Mode Control Port */ #define CRT_STATUS_REG_MONO 0X03BA /* 6845 display status port */ struct mono_display_adapter { unsigned present; /* if TRUE, MDA found */ unsigned active; /* if TRUE, MDA active */ }; extern struct mono_display_adapter mda; /* CGA-SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ #define CRT_INDEX_REG_COLOR 0X03D4 /* 6845 index register */ #define CRT_STATUS_REG_COLOR 0X03DA /* 6845 display status port */ struct color_graphics_adapter { unsigned present; /* if TRUE, CGA found */ unsigned active; /* if TRUE, CGA active */ }; extern struct color_graphics_adapter cga; /* HERCULES SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ struct hercules_graphics_adapter { unsigned present; /* if TRUE, Hercules board found */ unsigned active; /* if TRUE, Hercules board active */ unsigned ramfont; /* if TRUE, Ramfont support found */ }; extern struct hercules_graphics_adapter hga; #define ID_MASK 0X30 /* mask for GB112 presence test */ #define ID_CODE 0X10 /* value to test GB112 mask against */ #define DIAG 0 /* Hercules configurations */ #define HALF 1 #define FULL 3 #define SWITCH_PORT 0X03BF /* Hercules Graphics Card+ Software Switch Port */ #define RAMFONT_SEG 0X0B400 /* Ramfont segment address */ #define XMODEREG 0X14 /* GB112 Ramfont register -- select mode */ #define SCORE_REG 0X15 /* GB112 Ramfont register -- select uscore */ #define STRIKE_REG 0X16 /* GB112 Ramfont register -- select ostrike */ #define SCREEN_ON_BLINK 0X28 /* Hercules video on with blinking */ #define SCREEN_ON_NOBLINK 0X08 /* Hercules video on. Disable blinking */ #define SCREEN_OFF_TEXT 0X20 /* Hercules, blank screen */ /* EGA-SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ #define SAVE_PTR 0X04A8 /* EGA BIOS ptr. to the table of EGA info. ptrs. */ /* STRUCT PALETTE is a structure for storing contents of the EGA palette registers. NOTE: The overscan register is not included in this structure. */ struct ega_palette { BYTE color[16]; /* the 16 palette colors */ }; /* STRUCT PARMTABLE stores the whole ega parameter table for a video mode. */ struct ega_parmtable { BYTE cols, rows, pels; /* screen columns, rows, pixels per char */ BYTE page_len[2]; /* video page length (a word stored in bytes) */ BYTE seq[4]; /* sequencer parameters */ BYTE misc; /* miscellaneous */ BYTE crt[25]; /* crt controller parameters */ struct ega_palette (*palette); /* attribute controller parameters */ BYTE mode_ctl; /* contents of mode control register */ BYTE overscan; /* contents of mode control register */ BYTE color_plane; /* contents of color plane enable register */ BYTE hrz_panning; /* contents of horizontal pel panning register */ BYTE graph_parms[9]; /* graphics parameters */ }; struct enhanced_graphics_adapter { unsigned present; /* if TRUE, EGA present */ unsigned active; /* if TRUE, EGA active */ /* POINTER TO VIDEO PARMS FOR 23 MODES */ struct ega_parmtable (*p_egaparms)[23]; struct ega_palette a_palette[23], szero; char far *a_egaptrs[7]; /* array of EGA parameter pointers */ struct ega_parmtable far * far *old_save_ptr; }; extern struct enhanced_graphics_adapter ega; /* VGA SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ struct video_graphics_array { unsigned present; unsigned active; unsigned ps2; /* PS/2 Model (except moel 30) */ unsigned ps2_30; /* PS/2 Model 30 */ unsigned unknown; }; extern struct video_graphics_array vga; /* EGA AND VGA REGISTERS */ #define PRESET_ROW_SCAN 0X08 /* Address of preset row scan reg. of CRTC */ #define START_ADDRESS_HIGH 0X0C /* Address of start address h reg. of CRTC */ #define START_ADDRESS_LOW 0X0D /* Address of start address l reg. of CRTC */ #define LINE_COMPARE 0X18 /* CRTC line compare register. */ #define CRTC_OVERFLOW 0X07 /* CRTC overflow register. */ #define MAX_SCAN_LINE 0X09 /* CRTC maximum scan line register. */ #define AC_INDEX 0X3C0 /* Attribute Controller Index Register*/ #define AC_HPP 0X13 | 0X20 /* Horizontal Pel Panning Register */ #define AC_MCR 0X10 /* Attribute Controller Mode Control Reg. */ #define GA_INDEX 0X3CE /* Graphics Controller Address Reg. */ #define GA_MISC 0X6 /* offset of Miscellaneous Register */ /* EGA AND VGA ROM FONTS */ #define FONT8X14 14 #define FONT8X8 8 #define FONT9X14 9 #define FONT8X16 16 #define FONT9X16 17 /* PGA SPECIFIC MANIFEST CONSTANTS AND VARIABLES */ struct professional_graphics_adapter { unsigned present; unsigned active; }; extern int BIOS; /* if TRUE, write through the BIOS */ extern int SNOW; /* if TRUE, snow present on CGA */ extern int ERROR_KEY; /* if TRUE, popup menu choice invalid */ extern int enhanced_kbd_found; /* WINDOW MANAGEMENT ROUTINES */ #define MAX_WINDOWS 255 /* maximum number of active windows */ #define MAX_COLS 132 /* maximum permitted # of columns */ #define MAX_ROWS 50 /* maximum permitted # of rows */ #define MAX_SCREENS 255 /* maximum number of active vscreens*/ extern BYTE s_matrix[MAX_ROWS][MAX_COLS]; extern WINDOW *w_chain[MAX_WINDOWS]; /* Array of window addresses */ extern WINDOW *w_priority[MAX_WINDOWS+1]; /* Array of window addresses */ extern unsigned w_top; /* highest # window created */ extern VSCREEN *vs_chain[MAX_SCREENS]; /* Array of virtual sc. addr. */ /* TIME ROUTINES */ #define CLOCKS_PER_HOUR 65543335L /* x1,000 */ #define CLOCKS_PER_MIN 1092389L /* x1,000 */ #define CLOCKS_PER_DAY 1573033L /* BIOS clock ticks per day */ #define CLOCKS_PER_SEC 18.206481934 #define CLOCK_RATE 1193182L #define PORTB 0X61 #define CMD8253 0X43 #define CH0_8253 0X40 #define CH2_8253 0X42 #define LOW_TIME 0X46C #define HIGH_TIME 0X46E /* Pointer to the desired delay function (either bios_wait() or ms_wait() */ extern void (*pause)(double duration); /* The TSR on-screen clock */ extern CLOCK *p_clock; extern int clock_savess, clock_savesp, f_inclock; extern char clock_stack[]; extern char clock_atime[]; extern char *p_clock_atime; /* The TSR on-screen stopwatch */ extern CLOCK *p_watch; extern int alarm_savess, alarm_savesp, f_inalarm; extern char alarm_stack[]; extern char alarm_atime[]; extern char *p_alarm_atime; #if defined(__TURBOC__) || defined(MSC) void interrupt far isr_clock_(void); void interrupt far isr_stopwatch_(void); #else void interrupt isr_clock_(void); void interrupt isr_stopwatch_(void); #endif void deinstall_int1c_(CLOCK *p_clock); #define deinstall_clock(a) deinstall_int1c_((a)) #define deinstall_stopwatch(a) deinstall_int1c_((a)) #if defined(__TURBOC__) || defined(__POWERC) int install_int1c_(WINDOW *w, CLOCK **p_clock, int col, int row, int fc, int bc, void interrupt (far *isr)()); #elif defined (MSC) int install_int1c_(WINDOW *w, CLOCK **p_clock, int col, int row, int fc, int bc, void (interrupt far *isr)()); #endif #define install_clock(a, b, c, d, e, f) install_int1c_((a), (b), (c), (d), (e), (f), isr_clock_) #define install_stopwatch(a, b, c, d, e, f) install_int1c_((a), (b), (c), (d), (e), (f), isr_stopwatch_) int set_alarm(CLOCK *p_watch, unsigned long secs); /* ========================================================================== */ /* FUNCTIONS AND MACROS */ /* SYSTEM SUPPORT */ void blink_state(unsigned state); void free_virtual_screen_memory(VSCREEN *v); void free_window_memory(WINDOW *wnum); int get_ansi(void); int get_char_ht(void); unsigned get_startup_config_(void); void get_video_adapter(void); void init_colors(void); int init_video(void); void restore_adapter(void); void restore_video(void); void set_active_page(int pagenum); void set_write_page(int pagenum); void switch_adapter(int mode); int video_mode(int m); int video_off(void); int video_on(void); /**********************************************************************/ /* SCREEN I/O */ void clear_box(int fcol,int frow,int lcol,int lrow, int fcolor, int bcolor, int chr); void cleol(int fc, int bc); void cls(int fc, int bc); int draw_box(unsigned fcol, unsigned frow, unsigned lcol, unsigned lrow, int h, int v, int fc, int bc); int format_def_(FORMAT *pf, int action, int member, int newval); #define get_format(a, c) format_def_((a), GET, (c), 0X0) #define set_format(a, c, d) format_def_((a), SET, (c), (d)) int getatt(void); int getchr(void); void prints(int fcol, int frow, int fcolor, int bcolor, char *p_str); void printsf(int fcol, int frow, int fcolor, int bcolor, char *p_str,...); void putss(int fcolor, int bcolor, char *p_str); void scroll(int lines, int att); BYTE * select_boxchar_(int h, int v); void snow_read_(char *p_str, unsigned far *spos, unsigned slength); /* ASM */ int snow_write_(unsigned far *spos, char *p_str, unsigned slength);/* ASM */ void snow_writec_(unsigned far *spos,unsigned chr); /* ASM */ void snow_putc_(unsigned far *spos, unsigned chr); /* ASM */ void snow_puts_(unsigned far *spos, char *p_str); /* ASM */ /**********************************************************************/ /* WINDOWS */ int ambush_window(WINDOW *wnum, double d_factor); void border_window(WINDOW *wnum, BORDER *p_border, int h, int v, int fc, int bc); void clear_window(WINDOW *wnum, COLORS *pc, int fc, int bc, int ch); int create_window(WINDOW **wnum, unsigned width, unsigned height); int display_window(WINDOW *wnum, int fcol, int frow, unsigned priority); int explode_window(WINDOW *wnum, int fcol, int frow, int bc, int ex_type, double d_factor, unsigned priority); int hide_window(WINDOW *wnum); int load_window(WINDOW *wnum); int move_window(WINDOW *wnum, int direction); unsigned preserve_screen(unsigned width, unsigned height); void recolor_window(WINDOW *wnum, int fc, int bc); int scroll_window(WINDOW *wnum, int num, int fcolor, int bcolor); int shadow_window(WINDOW *wnum, SHADOW *ps, int loc_type, int color, int ch); int store_window(WINDOW *wnum, char *pf); void update_ownership_(WINDOW *wnum, unsigned priority, int action); void w_cursor(WINDOW *wnum, int col, int row); void w_printc(WINDOW *wnum, int col, int row, int fc, int bc, int ch); void w_printf(WINDOW *wnum, int fcolor, int bcolor, char *fs,...); void w_prints(WINDOW *wnum, int col, int row, int fc, int bc, char *p_str); void w_printsf(WINDOW *wnum, int col, int row, int fcolor, int bcolor, char *fs,...); int w_putc(WINDOW *wnum, int fcolor, int bcolor, int ch); void w_puts(WINDOW *wnum, int fcolor, int bcolor, char *p_str); void w_readr_(WINDOW *wnum, char *dest, int row); void w_write_(WINDOW *wnum); void w_writec_(WINDOW *wnum, int col, int row); void w_writer_(WINDOW *wnum, int row); /**********************************************************************/ /* VIRTUAL SCREENS */ void clear_virtual_screen(VSCREEN *vsnum, COLORS *pc, int fc, int bc, int ch); int create_virtual_screen(VSCREEN **vsnum, unsigned width, unsigned height); int pan_window(WINDOW *wnum, int num); void vs_cursor(VSCREEN *vsnum, unsigned col, unsigned row); void vs_printc(VSCREEN *vsnum, unsigned col, unsigned row, int fc, int bc, int ch); void vs_prints(VSCREEN *vsnum, unsigned col, unsigned row, int fc, int bc, char *p_str); void vs_printsf(VSCREEN *vsnum, unsigned col, unsigned row, int fc, int bc, char *fs,...); int vs_putc(VSCREEN *vsnum, int fc, int bc, int ch); int vs_puts(VSCREEN *vsnum, int fc, int bc, char *p_str); void vs_writec_(VSCREEN *vsnum, unsigned col, unsigned row); int vscreen_def_(VSCREEN *vsnum, int action, int member, int newval); #define get_virtual_screen(a, c) vscreen_def_((a), GET, (c)) #define set_virtual_screen(a, c, d) vscreen_def_((a), SET, (c), (d)) int w_load_vs(WINDOW *wnum, VSCREEN *vsnum, unsigned col, unsigned row); /**********************************************************************/ /* POPUP MENUS */ void add_select_bar(WINDOW *wnum, int fc, int bc, int lineno); int create_popup_menu(WINDOW **wnum, POPUP *p_pop1, VSCREEN **vsnum, unsigned width, unsigned height); int get_selection(WINDOW *wnum); int popup_def_(POPUP *pp, int action, int member, int newval); #define get_popup_menu(a, c) popup_def((a), GET, (c), 0X0) #define set_popup_menu(a, c, d) popup_def((a), SET, (c), (d)) void remove_select_bar(WINDOW *wnum, int fc, int bc); int select_item(WINDOW *wnum, int lineno); /**********************************************************************/ /* BIOS ACCESS -- VIDEO */ unsigned bios_getc(void); /* ASM */ void bios_putc(unsigned chr); /* ASM */ void bios_puts(char *p_sstr); /* ASM */ void bios_read(char *p_dstr, unsigned count); /* ASM */ void bios_write(int col, int row, char *p_sstr, unsigned count);/* ASM */ void bios_writec(unsigned col, unsigned row , int chr); /* ASM */ /* CURSOR */ int curs(int state); void cursor(unsigned col, unsigned row); #define cursor_off() curs(OFF) #define cursor_on() curs(ON) void cursorx(unsigned col, unsigned row, int page); unsigned get_cursor_position(unsigned *ccol, unsigned *crow); unsigned get_cursor_size(void); unsigned get_cursorx_position(unsigned *ccol, unsigned *crow, int page); void set_cursor_size(int top_line, int bottom_line); /*********************************************************************/ /* KEYBOARD */ /* The following function provides access to BIOS keyboard services, including the services provided when the Enhanced Keyboard is present and supported by the BIOS. It is a more versatile alternative to the function bioskey() in the TURBOC compiler library and _bios_keybrd() in the MSC library. */ unsigned bios_key(int func); unsigned bk_(int func); /* ASM */ int check_kbd_bios_(void); void clear_kbd(void); int get_kbd(void); unsigned get_key(int *scan, int *key); int key_ready(void); int wait_key(int key, double duration); int kbd_state_(int func, int mask); #define caps_lock_state() kbd_state_((2), (0X40)) #define insert_state() kbd_state_((2), (0X80)) #define left_shift_state() kbd_state_((2), (0X02)) #define num_lock_state() kbd_state_((2), (0X20)) #define right_shift_state() kbd_state_((2), (0X01)) #define scroll_lock_state() kbd_state_((2), (0X10)) /*********************************************************************/ /* EGA/VGA-SPECIFIC */ void get_romfont(char *fptr, int font); int get_egaparms(void); void get_palette_(char far *ram_palette, int v_mode); void init_palette(void); void load_color(int color, int oldcolor, int mode); void load_palette(int v_mode); void load_romfont(int font, int block); /* combine */ int load_romxfont(int font, int block); void load_user_font(char far *fptr,int block,int bpc,int char_count,int spos); void reset_saveptr(void); void set_color(int newcolor, int oldcolor, int mode); void set_line_compare(int scan_line); unsigned set_logical_screen_width(unsigned l_width); void set_pel_pan_(int hpel); int set_scan_lines(int lines, int execute); int set_screen_rows(int rows); void set_start_addr(unsigned start_addr); int set_video_pages(int num); void smooth_pan(int count, unsigned speed); void smooth_scroll(int count, unsigned speed); /* void two_fonts(int state, int hi); */ void two_fonts(int state, int hi, int hiblock, int loblock); /*********************************************************************/ /* HERCULES-SPECIFIC */ char * hercparms_(unsigned i); int hercules_present(void); int load_ramfont(char *p_fspec, int state, int fontmode, int width, int height); void program6845_(int fontmode, int width, int height); int ramfont_support_found(void); void set_hercules_config(int config); void set_herc_ramfont_reg(int line, int func); #define set_herc_underscore_reg(a) set_herc_ramfont_reg((a), SCORE_REG) #define set_herc_overstrike_reg(a) set_herc_ramfont_reg((a), STRIKE_REG) /*********************************************************************/ /* DATA-ENTRY FUNCTIONS */ int add_field_(VSCREEN *vs, FIELD *f); void adjust_cursor_size_(void); int check_key_(FIELD *f, char *pos, int scan, int key); int create_field(FIELD *pf, VSCREEN *vs, COLORS *pc, int (*p_e)(), int *a_n, int id, int col, int row, char *fs); int edit_field(FIELD *f); int f_cursor(FIELD *f, int col, int row); int f_putc_(FIELD *f, int fc, int bc, int ch); int in_set_(char *ps, int key); int input_field(FIELD *f, char fc, char bc, char *fs); int isdisplayed_(VSCREEN *v, unsigned col, unsigned row); int isvalidfield_(FIELD *f); int isvalidkey_(FIELD *f, int scan, int key); void insert_field_(FIELD *p, FIELD *f); int isneutral_(int *neutrals, int scan, int key); int parse_field(FIELD *f, char *dest, unsigned num); /*********************************************************************/ /* POINTERS TO USER_DEFINED FUNCTIONS */ extern int (*p_user_popup1)(WINDOW *w, int keyinfo); extern int (*p_user_popup2)(WINDOW *w, int keyinfo); /*********************************************************************/ /* THE EDITOR */ int add_line(BUFFER *pb); int create_wrap_buffer(BUFFER *b); int create_editor(VSCREEN **v, unsigned cols, unsigned rows, BUFFER *b, MENU_KEYS *k, FORMAT *f); int cursor_down(BUFFER *b); int cursor_left(BUFFER *b); int cursor_right(BUFFER *b); int cursor_up(BUFFER *b); int dispatch(BUFFER *b); int e_cursor(BUFFER *b, unsigned col, unsigned row); int fill_wrap_buf_(BUFFER *b, LINE *l); char *find_white_space_(const char *s, int direction, int range); int free_editor_memory(BUFFER *b); int insert_char(BUFFER *b, int ch, int pos); int load_edit_file(BUFFER *b, char *fname); int overwrite_char(BUFFER *b, int ch, int pos); int reformat_para_(BUFFER *b); int save_edit_file(BUFFER *b, char *fname); int v_load_ed(BUFFER *pb, LINE *l); /*********************************************************************/ /* MISCELLANEOUS FUNCTIONS */ void cvrt_(char *p, int num); void deinstall_local_stack_(int *old_ss, int *old_sp); void install_local_stack_(char *local_stack, unsigned len, int *old_ss, int *old_sp); #if !defined(TELECOMM_H_INCLUDED) void bios_delay(double duration); /* using BIOS time-of-day */ int inkey(void); int make_sound(unsigned pitch, double duration); void ms_delay(double duration); /* using 8253 timer */ void set_sound_off(void); void start_timer(long *start); void stop_timer(long *start, long *stop, double *elapsed_time); #endif /* COMPILER-SPECIFIC MACROS FOR SOURCE CODE COMPATIBILITY */ #if defined(MSC) /* The following macros provide an alternative means of addressing the ports. They make MSC 5.0+/Quick C 1.0+ code and Turbo C code compatible and are used internally. */ #define inport(port) inpw(port) #define outport(port,value) outpw((port),(value)) /* THE FOLLOWING ROUTINES MAKE SOME MSC FUNCTIONS CONSISTENT WITH TURBO C */ #define disable() _disable() #define enable() _enable() #define getvect(a) _dos_getvect(a) #define setvect(a, b) _dos_setvect((a), (b)) #define farcalloc(a, b) halloc((a), (b)) #define farfree(a) hfree((a)) long biostime(int service, long timeval); /* The following function creates a far pointer at a user-specified address and is used internally. */ void far *MK_FP(unsigned pseg, unsigned poff); /* The following macro creates a far pointer at a user-specified address It is commented out due to a suspected bug in MSC v5.0 */ /* #define MK_FP(seg,ofs) ((void far *)((((unsigned long)(seg)) << 16) | (ofs))) */ void restore_ega_cursor(int bpc); /* The following 4 macros emulate BASIC's "peek" and "poke" routines. They are used internally. */ #define poke(a,b,c) (*((int far*)MK_FP((a),(b))) = (int)(c)) #define pokeb(a,b,c) (*((char far*)MK_FP((a),(b))) = (char)(c)) #define peek(a,b) (*((int far*)MK_FP((a),(b)))) #define peekb(a,b) (*((char far*)MK_FP((a),(b)))) #endif #if defined(__POWERC) extern BYTE ppage_; #endif #if defined(__POWERC) || defined(__TURBOC__) #define outpw(port, value) outport((port),(value)) #endif #define CWINDOWS_H_INCLUDED #endif