home *** CD-ROM | disk | FTP | other *** search
- /*
- * The routines in this file provide support for the TI-PC and other
- * compatible terminals. It goes directly to the alpha-numeric RAM to do
- * screen output. It compiles into nothing if not a TI-PC driver.
- * This is not the TIPC.C file Dan distributed but it did not work due to
- * lack of current updates. It also used all DSR calls. This version
- * does directly write to screen ram in most cases. It has only been
- * tested under Lattice 3.1 at this time though. ( BIX id ronlepine */
-
- #define termdef 1 /* don't define "term" external */
-
- #include <stdio.h>
- #include "estruct.h"
- #include "edef.h"
-
- #if TIPC
-
- #define NROW 25 /* Screen size. */
- #define NCOL 80 /* Edit if you want to. */
- #define MARGIN 8 /* size of minimim margin and */
- #define SCRSIZ 64 /* scroll size for extended lines */
- #define NPAUSE 200 /* # times thru update to pause */
- #define BEL 0x07 /* BEL character. */
- #define ESC 0x1B /* ESC character. */
- #define SPACE 32 /* space character */
- #define SCADD 0xDE000000L /* address of screen RAM */
- #define ATTRADD 0xDE001800L /* Address for attribute latch */
- #define CHAR_ENABLE 0x08 /* TI attribute to show char */
- #define TI_REVERSE 0x10 /* TI attribute to reverse char */
- #define BLACK 0+CHAR_ENABLE /* TI attribute for Black */
- #define BLUE 1+CHAR_ENABLE /* TI attribute for Blue */
- #define RED 2+CHAR_ENABLE /* TI attribute for Red */
- #define MAGENTA 3+CHAR_ENABLE /* TI attribute for Magenta */
- #define GREEN 4+CHAR_ENABLE /* TI attribute for Green */
- #define CYAN 5+CHAR_ENABLE /* TI attribute for Cyan */
- #define YELLOW 6+CHAR_ENABLE /* TI attribute for Yellow */
- #define WHITE 7+CHAR_ENABLE /* TI attribute for White */
-
- extern int ttopen(); /* Forward references. */
- extern int ttgetc();
- extern int ttputc();
- extern int ttflush();
- extern int ttclose();
- extern int timove();
- extern int tieeol();
- extern int tieeop();
- extern int tibeep();
- extern int tiopen();
- extern int tikopen();
- extern int tikclose();
- extern int tirev();
- extern int ticres();
- extern int ticlose();
- extern int tiputc();
- extern int tifcol();
- extern int tibcol();
- extern int tiwrattr();
- extern union REGS rg; /* cpu register for use of DOS calls */
-
-
- int cfcolor = -1; /* current forground color */
- int cbcolor = -1; /* current background color */
- int ctrans[] = /* ansi to ti color translation table */
- {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
-
- long scadd = SCADD; /* address of screen ram */
- long attradd = ATTRADD; /* address of attribute latch */
- int *scptr[NROW]; /* pointer to screen lines */
- char sline[NCOL]; /* screen line image */
-
-
- /*
- * Standard terminal interface dispatch table. Most of the fields point into
- * "termio" code.
- */
- TERM term = {
- NROW-1,
- NROW-1,
- NCOL,
- NCOL,
- MARGIN,
- SCRSIZ,
- NPAUSE,
- tiopen,
- ticlose,
- tikopen,
- tikclose,
- ttgetc,
- tiputc,
- ttflush,
- timove,
- tieeol,
- tieeop,
- tibeep,
- tirev,
- ticres,
- tifcol,
- tibcol
- };
-
-
- tifcol(color) /* set the current output color */
-
- int color; /* color to set. Actually only used for line 25 */
-
- {
- cfcolor = ctrans[color];
- memset(attradd, cfcolor, 1);
- }
-
- tibcol(color) /* set current background color. Not used. Background is */
- /* graphics function on TI */
- int color; /* color to set */
-
- {
- /* not used in memmap driver */
- }
-
- timove(row, col)
- {
- rg.h.ah = 2; /* set cursor position function code */
- rg.h.dh = col;
- rg.h.dl = row;
- int86(0x49, &rg, &rg);
- }
-
- tieeol() /* erase to the end of the line */
-
- {
- int ccol; /* current column cursor lives */
- int crow; /* current row cursor lives */
- char *lnptr; /* pointer to the destination line */
- char i;
-
- /* find the current cursor position */
- rg.h.ah = 3; /* read cursor position function code */
- int86(0x49, &rg, &rg);
- ccol = rg.h.dh; /* record current column */
- crow = rg.h.dl; /* and row */
-
- lnptr = &sline[0];
- for (i=0; i < term.t_ncol; i++)
- *lnptr++ = SPACE;
- /* and send the string out */
- movmem(&sline[0], scptr[crow]+ccol, term.t_ncol-ccol);
-
- }
-
- tiputc(ch) /* put a character at the current position in the
- current colors */
-
- int ch;
-
- {
- rg.h.ah = 0x0E; /* write char to screen with current attrs */
- rg.h.al = ch;
- int86(0x49, &rg, &rg);
- }
-
- tieeop() /* Clear Text Screen and Home Cursor */
- { /* This also sets logical col 1, row 1 */
- rg.h.ah = 0x13; /* to physical col 1, row 1. Avoid hard-*/
- int86(0x49, &rg, &rg); /* ware scroll which will change the pointer */
- }
-
- tirev(state) /* change reverse video state */
-
- int state; /* TRUE = reverse, FALSE = normal */
-
- {
- /* Should not be accessed by memmap driver */
- }
-
- ticres() /* change screen resolution - not used */
- /* TI uses only 720 x 300 res text mode */
- {
- return(TRUE);
- }
-
- spal() /* change palette string */
-
- {
- /* Does nothing here - don't know what Dan plans are */
- }
-
- tikopen()
-
- {
- /* No need to change keyboard mode */
- }
-
- tikclose()
-
- {
- /* No need to close */
- }
-
- tibeep()
- {
- bdos(6, BEL, 0);
- }
-
- tiopen()
- {
- tieeop(); /* Make logical = physical screen pointers */
- scinit();
- strcpy(sres, "NORMAL");
- revexist = TRUE;
- ttopen();
- }
-
- #if FLABEL
- fnclabel (f, n) /* label a function key */
-
- int f,n; /* default flag, numeric argument [unused] */
-
- {
- /* Don't bother. All function keys can be bound on the fly */
- return(TRUE);
- }
- #endif
-
- ticlose()
-
- {
- tifcol(7);
- ttclose();
-
- }
-
- scinit() /* initialize the screen head pointers */
-
- {
- union {
- long laddr; /* long form of address */
- int *paddr; /* pointer form of address */
- } addr;
-
- char i;
-
- /* initialize the screen pointer array */
- for (i = 0; i < NROW; i++) {
- addr.laddr = scadd + (long)(NCOL * i);
- scptr[i] = addr.paddr;
- }
- }
-
- scwrite(row, outstr, forg, bacg) /* write a line out*/
-
- int row; /* row of screen to place outstr on */
- char *outstr; /* string to write out (must be term.t_ncol long) */
- int forg; /* forground color of string to write */
- int bacg; /* background color */
-
- {
- char *lnptr; /* pointer to the destination line */
- char i;
-
- /* write the attribute byte to latch and setup the screen pointer */
- if (forg == 0) { /*Then you can change the back ground to color */
- bacg = ctrans[bacg] + TI_REVERSE;
- memset(attradd, bacg, 1);
- }
- else {
- forg = ctrans[forg];
- memset(attradd, forg, 1);
- }
-
- lnptr = &sline[0];
- for (i=0; i<term.t_ncol; i++)
- *lnptr++ = outstr[i];
- /* and send the string out */
- movmem(&sline[0], scptr[row], term.t_ncol);
-
- }
- #else
- tihello()
- {
- }
- #endif
-
-