|
|
1.1 ! root 1: /* ! 2: * The routines in this file provide support for the ATARI ST video and ! 3: * keyboard subsystem, though much of the ST specific keyboard support is ! 4: * in "termio.c". It compiles into nothing if the GEM and NATIVE variants ! 5: * are not selected. The ST video subsystem is very much like the VT52. ! 6: */ ! 7: #include <stdio.h> ! 8: #include "ed.h" ! 9: ! 10: #if GEM && NATIVE ! 11: #include <osbind.h> ! 12: #include <linea.h> ! 13: ! 14: #define NROW 25 /* Normal screen size. */ ! 15: #define MROW 40 /* Long screen size. */ ! 16: #define LROW 50 /* Very long screen size. */ ! 17: ! 18: #define NCOL 80 /* Number of columns */ ! 19: ! 20: #define BIAS 0x20 /* Origin 0 coordinate bias. */ ! 21: #define ESC 0x1B /* ESC character. */ ! 22: #define BEL 0x07 /* ascii bell character */ ! 23: ! 24: extern int ttopen(); /* Forward references. */ ! 25: extern int ttgetc(); ! 26: extern int ttputc(); ! 27: extern int ttflush(); ! 28: extern int ttclose(); ! 29: extern int astmove(); ! 30: extern int asteeol(); ! 31: extern int asteeop(); ! 32: extern int astbeep(); ! 33: extern int astopen(); ! 34: extern int astclose(); ! 35: extern int astandout(); ! 36: ! 37: /* ! 38: * Dispatch table. All the ! 39: * hard fields just point into the ! 40: * terminal I/O code. ! 41: */ ! 42: TERM term = { ! 43: NROW-1, ! 44: NCOL, ! 45: astopen, ! 46: astclose, ! 47: ttgetc, ! 48: ttputc, ! 49: ttflush, ! 50: astmove, ! 51: asteeol, ! 52: asteeop, ! 53: astbeep, ! 54: astandout ! 55: }; ! 56: ! 57: astmove(row, col) /* set cursor position */ ! 58: { ! 59: tputc(ESC); ! 60: tputc('Y'); ! 61: tputc(row+BIAS); ! 62: tputc(col+BIAS); ! 63: } ! 64: ! 65: asteeol() /* Erase to end of line */ ! 66: { ! 67: tputc(ESC); ! 68: tputc('K'); ! 69: } ! 70: ! 71: asteeop() /* Erase to end of page */ ! 72: { ! 73: tputc(ESC); ! 74: tputc('J'); ! 75: } ! 76: ! 77: astseeop() /* Special end-of-page for 40 line mode. */ ! 78: { ! 79: register int i; ! 80: ! 81: i = V_CEL_MY; /* Line-A is already initialized by open */ ! 82: V_CEL_MY = LROW-1; /* Save # lines, claim full length... */ ! 83: asteeop(); /* Clear to end of line */ ! 84: V_CEL_MY = i; /* Restore actual # of lines... */ ! 85: } ! 86: ! 87: astbeep() /* Sound the terminal bell */ ! 88: { ! 89: tputc(BEL); ! 90: tflush(); ! 91: } ! 92: ! 93: astandout(f) /* Set/clear standout mode... */ ! 94: { ! 95: tputc(ESC); ! 96: tputc((f == 0) ? 'q' : 'p'); /* Set or clear reverse video */ ! 97: } ! 98: ! 99: astcursor(f) /* Show/hide text cursor */ ! 100: { ! 101: tputc(ESC); ! 102: tputc((f == 0) ? 'f' : 'e'); /* Set or clear reverse video */ ! 103: } ! 104: ! 105: astopen() /* Open the "terminal" */ ! 106: { ! 107: tputc(ESC); ! 108: tputc('f'); ! 109: if (runswitch & CF_VLONG) { ! 110: if (setlines(1) == 0) { ! 111: term.t_nrow = LROW-1; ! 112: } else ! 113: runswitch &= ~(CF_VLONG|CF_LONGSCR); ! 114: } else if (runswitch & CF_LONGSCR) { ! 115: if (setlines(-1) == 0) { ! 116: term.t_eeop = astseeop; ! 117: term.t_nrow = MROW-1; ! 118: } else ! 119: runswitch &= ~(CF_VLONG|CF_LONGSCR); ! 120: } ! 121: tputc(ESC); ! 122: tputc('e'); ! 123: ttopen(); ! 124: } ! 125: ! 126: astclose() /* Close the terminal */ ! 127: { ! 128: if (runswitch & (CF_VLONG|CF_LONGSCR)) { ! 129: astcursor(0); ! 130: setlines(0); ! 131: astmove(NROW-2, 0); ! 132: astcursor(1); ! 133: tputc('\n'); ! 134: } ! 135: ttclose(); ! 136: } ! 137: ! 138: /* ! 139: * Set the screen to 25, 40 or 50 lines, base on FLAG. Return 0 if ! 140: * successful (Monochrome), or 1 if not (Color). ! 141: * ! 142: * Flag value # lines ! 143: * -1 40 ! 144: * 0 25 ! 145: * 1 50 ! 146: */ ! 147: ! 148: setlines(flag) ! 149: { ! 150: register struct la_font *fnthdr; ! 151: ! 152: if (Getrez() != 2) /* If not monochrome... */ ! 153: return 1; /* Return non-zero */ ! 154: linea0(); /* Initialize Line-A */ ! 155: if (flag) { /* If long screen request... */ ! 156: fnthdr = (la_init.li_a1)[1]; /* Get the font header */ ! 157: /* for 8x8 font */ ! 158: if (flag > 0) { /* If 50 line request */ ! 159: V_CEL_MY = 49; /* 50 lines */ ! 160: V_CEL_WR = 640; /* offset (in bytes) to next row */ ! 161: } else { /* Otherwise 40 lines */ ! 162: V_CEL_MY = 39; /* 40 lines */ ! 163: V_CEL_WR = 800; /* offset (in bytes) to next row */ ! 164: } ! 165: } else { /* Otherwise, short screen request */ ! 166: fnthdr = (la_init.li_a1)[2]; /* Get the font header */ ! 167: /* for the 8*16 font */ ! 168: V_CEL_MY = 24; /* 25 lines */ ! 169: V_CEL_WR = 1280; /* offset (in bytes) to next row */ ! 170: } ! 171: V_CEL_HT = fnthdr->font_height; /* Set system font */ ! 172: V_OFF_AD = (long)(fnthdr->font_char_off); ! 173: V_FNT_AD = (long)(fnthdr->font_data); ! 174: return 0; /* return success. */ ! 175: } ! 176: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.