[BACK]Return to atariaes.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/atariaes.trm, Revision 1.1.1.1

1.1       maekawa     1: /*
                      2:  * $Id: atariaes.trm,v 1.9 1998/06/18 14:59:17 ddenholm Exp $
                      3:  *
                      4:  */
                      5:
                      6: /* GNUPLOT - atari.trm */
                      7:
                      8: /*[
                      9:  * Copyright 1992, 1993, 1998
                     10:  *
                     11:  * Permission to use, copy, and distribute this software and its
                     12:  * documentation for any purpose with or without fee is hereby granted,
                     13:  * provided that the above copyright notice appear in all copies and
                     14:  * that both that copyright notice and this permission notice appear
                     15:  * in supporting documentation.
                     16:  *
                     17:  * Permission to modify the software is granted, but not the right to
                     18:  * distribute the complete modified source code.  Modifications are to
                     19:  * be distributed as patches to the released version.  Permission to
                     20:  * distribute binaries produced by compiling modified sources is granted,
                     21:  * provided you
                     22:  *   1. distribute the corresponding source modifications from the
                     23:  *    released version in the form of a patch file along with the binaries,
                     24:  *   2. add special version identification to distinguish your version
                     25:  *    in addition to the base release version number,
                     26:  *   3. provide your name and address as the primary contact for the
                     27:  *    support of your modified version, and
                     28:  *   4. retain our contact information in regard to use of the base
                     29:  *    software.
                     30:  * Permission to distribute the released version of the source code along
                     31:  * with corresponding source modifications in the form of a patch file is
                     32:  * granted with same provisions 2 through 4 for binary distributions.
                     33:  *
                     34:  * This software is provided "as is" without express or implied warranty
                     35:  * to the extent permitted by applicable law.
                     36: ]*/
                     37:
                     38: /*
                     39:  * This file is included by ../term.c.
                     40:  *
                     41:  * This terminal driver supports:
                     42:  *   Atari Screens working with the normal VDI
                     43:  *     (this should include TT and big screens)
                     44:  *
                     45:  * AUTHORS
                     46:  *  Alexander Lehmann
                     47:  *  HE Koechling
                     48:  *
                     49:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     50:  *
                     51:  * ATARI-related comments please to alexlehm@iti.informatik.th-darmstadt.de
                     52:  *
                     53:  */
                     54:
                     55: #include "driver.h"
                     56:
                     57: #ifdef TERM_REGISTER
                     58: register_term(atari)
                     59: #endif
                     60:
                     61: #ifdef TERM_PROTO
                     62:
                     63: /* function-prototypes */
                     64: TERM_PUBLIC void ATARI_options __PROTO((void));
                     65: TERM_PUBLIC void ATARI_init __PROTO((void));
                     66: TERM_PUBLIC void ATARI_reset __PROTO((void));
                     67: TERM_PUBLIC void ATARI_graphics __PROTO((void));
                     68: TERM_PUBLIC void ATARI_text __PROTO((void));
                     69: TERM_PUBLIC void ATARI_move __PROTO((unsigned int x, unsigned int y));
                     70: TERM_PUBLIC void ATARI_vector __PROTO((unsigned int x, unsigned int y));
                     71: TERM_PUBLIC void ATARI_linetype __PROTO((int lt));
                     72: TERM_PUBLIC void ATARI_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                     73: TERM_PUBLIC int ATARI_text_angle __PROTO((int ang));
                     74: TERM_PUBLIC int ATARI_justify_text __PROTO((enum JUSTIFY mode));
                     75: TERM_PUBLIC void ATARI_point __PROTO((unsigned int x, unsigned int y, int number));
                     76:
                     77: /* default to hi-res */
                     78: #define ATARI_XMAX 640
                     79: #define ATARI_YMAX 400
                     80: #define ATARI_VCHAR 16
                     81: #define ATARI_HCHAR 8
                     82: #define ATARI_HTIC (ATARI_XMAX/100)
                     83: #define ATARI_VTIC ATARI_HTIC
                     84:
                     85: #endif /* TERM_PROTO */
                     86:
                     87: #ifndef TERM_PROTO_ONLY
                     88: #ifdef TERM_BODY
                     89:
                     90: #ifdef __PUREC__
                     91: /* why did they have to change these names ??? */
                     92: # include <aes.h>
                     93: # include <vdi.h>
                     94: # include <tos.h>
                     95: #else /* !__PUREC__ i.e. __GNUC__, maybe others */
                     96: # include <aesbind.h>
                     97: # include <vdibind.h>
                     98: # include <osbind.h>
                     99: extern short _global[];
                    100: #endif
                    101:
                    102: #include <ctype.h>
                    103:
                    104: static void open_window __PROTO((void));
                    105: static void close_window __PROTO((void));
                    106: static void text_mode __PROTO((void));
                    107: static void mouse_mode __PROTO((void));
                    108: static void application_exit __PROTO((void));
                    109: void application_init __PROTO((void));
                    110: static int intersect __PROTO((int *x1, int *y1, int *w1, int *h1, int x2, int y2, int w2, int h2));
                    111: static void walk_rects __PROTO((void (*draw) (int, int, int, int), int x1, int y1, int w1, int h1));
                    112: static void clear __PROTO((int x, int y, int w, int h));
                    113: static void process_message __PROTO((int *msg));
                    114: long poll_events __PROTO((int waitkey));
                    115: static void f_line __PROTO((int x, int y, int w, int h));
                    116: static void flush_line __PROTO((void));
                    117: static void put_text __PROTO((int x, int y, int w, int h));
                    118:
                    119: static int multi_aes;
                    120: static int window_id = -1;
                    121: static int vdi_handle = -1;
                    122: static int win_xpos, win_ypos;
                    123: static int win_xsize, win_ysize;
                    124:
                    125: #define ATARI_yc(y) (ATARI_maxycoord-(y))
                    126: static int ATARI_linetypes[] =
                    127: {
                    128:     0xffff, 0x1111,
                    129:     0xffff, 0x5555, 0x3333, 0x7777,
                    130:     0x3f3f, 0x0f0f, 0x5f5f, 0xe4e4, 0x55f5
                    131: };
                    132:
                    133: #define ATARI_LINETYPES_MAX     (sizeof(ATARI_linetypes)/sizeof(int))
                    134:
                    135: static int ATARI_lt;
                    136: static int ATARI_maxycoord;
                    137: static int ATARI_rotation;
                    138: static int ATARI_numcolors;
                    139: static int pxy[128];           /* Maximum of 64 pixels per v_pline */
                    140: static int pxy_index;
                    141: static int ATARI_colors[16];
                    142: static int ATARI_savecolors[16][3];
                    143: static int ATARI_numpalette;
                    144:
                    145: #define ATARI_c_height_default 6       /* well, well ...               */
                    146:
                    147: static int ATARI_c_height = ATARI_c_height_default;
                    148:
                    149: static int cursor_is_on = FALSE;
                    150: static int put_text_x;
                    151: static int put_text_y;
                    152: static char *put_text_str;
                    153:
                    154: /* don't change this without changing process_message() below */
                    155: #define WINTYPE (NAME|CLOSER|FULLER|MOVER|SIZER)
                    156:
                    157: static void open_window(void)
                    158: {
                    159:     int x, y, w, h;
                    160:
                    161:     if (window_id == -1) {
                    162:        wind_calc(WC_BORDER, WINTYPE, win_xpos, win_ypos,
                    163:                  win_xsize, win_ysize, &x, &y, &w, &h);
                    164:        window_id = wind_create(WINTYPE, x, y, w, h);
                    165:
                    166:        if (window_id < 0) {
                    167:            window_id = -1;
                    168:            int_error("Can't create window", NO_CARET);
                    169:        }
                    170:        wind_set(window_id, WF_NAME, "gnuplot output");
                    171:        wind_open(window_id, x, y, w, h);
                    172:     }
                    173: }
                    174:
                    175: static void close_window(void)
                    176: {
                    177:     if (window_id != -1) {
                    178:        wind_close(window_id);
                    179:        wind_delete(window_id);
                    180:        window_id = -1;
                    181:     }
                    182: }
                    183:
                    184: static void text_mode(void)
                    185: {
                    186:     if (!multi_aes) {
                    187:        if (!cursor_is_on) {
                    188:            cursor_is_on = TRUE;
                    189:            graf_mouse(M_OFF, NULL);
                    190:            fputs("\033e", stderr);
                    191:        }
                    192:        fputs("\033E", stderr);
                    193:     }
                    194: }
                    195:
                    196: static void mouse_mode(void)
                    197: {
                    198:     if (!multi_aes) {
                    199:        if (cursor_is_on) {
                    200:            cursor_is_on = FALSE;
                    201:            graf_mouse(M_ON, NULL);
                    202:            fputs("\033f", stderr);
                    203:        }
                    204:     }
                    205: }
                    206:
                    207: static void application_exit(void)
                    208: {
                    209:     close_window();
                    210:
                    211:     if (vdi_handle != -1) {
                    212:        v_clsvwk(vdi_handle);
                    213:     }
                    214:     mouse_mode();
                    215: }
                    216:
                    217: void application_init(void)
                    218: {
                    219:     if (aesid < 0) {
                    220:        if ((aesid = appl_init()) < 0)
                    221:            int_error("APPL_INIT failed !", NO_CARET);
                    222:     }
                    223: #ifdef __PUREC__
                    224:     multi_aes = _GemParBlk.global[1] == -1;
                    225: #else
                    226:     /* tested with gcc only */
                    227:     multi_aes = _global[1] == -1;
                    228: #endif
                    229:
                    230:     if (!multi_aes)
                    231:        graf_mouse(ARROW, NULL);
                    232:     else
                    233:        menu_register(aesid, "  Terminal: atari");
                    234:
                    235:     text_mode();
                    236:     atexit(application_exit);
                    237: }
                    238:
                    239: static int intersect(int *x1, int *y1, int *w1, int *h1, int x2, int y2, int w2, int h2)
                    240: {
                    241:     if (*x1 > x2) {
                    242:        w2 -= *x1 - x2;
                    243:        x2 = *x1;
                    244:     } else {
                    245:        (*w1) -= x2 - *x1;
                    246:        *x1 = x2;
                    247:     }
                    248:     if (*y1 > y2) {
                    249:        h2 -= *y1 - y2;
                    250:        y2 = *y1;
                    251:     } else {
                    252:        (*h1) -= y2 - *y1;
                    253:        *y1 = y2;
                    254:     }
                    255:     if (*w1 > w2) {
                    256:        *w1 = w2;
                    257:     } else {
                    258:        w2 = *w1;
                    259:     }
                    260:     if (*h1 > h2) {
                    261:        *h1 = h2;
                    262:     } else {
                    263:        h2 = *h1;
                    264:     }
                    265:
                    266:     return (*w1) > 0 && (*h1) > 0;
                    267: }
                    268:
                    269: static void walk_rects(void (*draw) (int, int, int, int), int x1, int y1, int w1, int h1)
                    270: {
                    271:     int x, y, w, h;
                    272:     int pxy[4];
                    273:
                    274:     wind_update(BEG_UPDATE);
                    275:     graf_mouse(M_OFF, NULL);
                    276:
                    277:     wind_get(window_id, WF_FIRSTXYWH, &x, &y, &w, &h);
                    278:     while (w > 0 && h > 0) {
                    279:        if (intersect(&x, &y, &w, &h, x1, y1, w1, h1)) {
                    280:            pxy[0] = x;
                    281:            pxy[1] = y;
                    282:            pxy[2] = x + w - 1;
                    283:            pxy[3] = y + h - 1;
                    284:            vs_clip(vdi_handle, 1, pxy);
                    285:            (*draw) (x, y, w, h);
                    286:        }
                    287:        wind_get(window_id, WF_NEXTXYWH, &x, &y, &w, &h);
                    288:     }
                    289:     vs_clip(vdi_handle, 0, pxy);
                    290:     graf_mouse(M_ON, NULL);
                    291:     wind_update(END_UPDATE);
                    292: }
                    293:
                    294: static void clear(int x, int y, int w, int h)
                    295: {
                    296:     static MFDB mfdb =
                    297:     {NULL};
                    298:     int pxy[8];
                    299:
                    300:     pxy[0] = pxy[4] = x;
                    301:     pxy[1] = pxy[5] = y;
                    302:     pxy[2] = pxy[6] = x + w - 1;
                    303:     pxy[3] = pxy[7] = y + h - 1;
                    304:
                    305:     vro_cpyfm(vdi_handle, ALL_WHITE /*0 */ , pxy, &mfdb, &mfdb);
                    306: }
                    307:
                    308: static void process_message(int *msg)
                    309: {
                    310:     static int is_fulled = FALSE;
                    311:     static int small_xpos, small_ypos, small_xsize, small_ysize;
                    312:     int x, y, w, h;
                    313:
                    314:     if (window_id == -1 || msg[3] != window_id)
                    315:        return;
                    316:
                    317:     switch (msg[0]) {
                    318:     case WM_REDRAW:
                    319:        walk_rects(clear, msg[4], msg[5], msg[6], msg[7]);
                    320:        break;
                    321:
                    322:     case WM_CLOSED:
                    323:        close_window();
                    324:        break;
                    325:
                    326:     case WM_TOPPED:
                    327:        wind_set(window_id, WF_TOP, window_id);
                    328:        break;
                    329:
                    330:     case WM_MOVED:
                    331:     case WM_SIZED:
                    332:        is_fulled = 0;
                    333:        wind_calc(WC_WORK, WINTYPE, msg[4], msg[5], msg[6], msg[7],
                    334:                  &win_xpos, &win_ypos, &win_xsize, &win_ysize);
                    335:        wind_set(window_id, WF_CURRXYWH, msg[4], msg[5], msg[6], msg[7]);
                    336:        break;
                    337:
                    338:     case WM_FULLED:
                    339:        if (!is_fulled) {
                    340:            is_fulled = TRUE;
                    341:            small_xpos = win_xpos;
                    342:            small_ypos = win_ypos;
                    343:            small_xsize = win_xsize;
                    344:            small_ysize = win_ysize;
                    345:
                    346:            wind_get(0, WF_WORKXYWH, &x, &y, &w, &h);
                    347:            wind_calc(WC_WORK, WINTYPE, x, y, w, h, &win_xpos, &win_ypos,
                    348:                      &win_xsize, &win_ysize);
                    349:        } else {
                    350:            is_fulled = FALSE;
                    351:            win_xpos = small_xpos;
                    352:            win_ypos = small_ypos;
                    353:            win_xsize = small_xsize;
                    354:            win_ysize = small_ysize;
                    355:        }
                    356:        wind_calc(WC_BORDER, WINTYPE, win_xpos, win_ypos, win_xsize,
                    357:                  win_ysize, &x, &y, &w, &h);
                    358:        wind_set(window_id, WF_CURRXYWH, x, y, w, h);
                    359:        break;
                    360:     }
                    361: }
                    362:
                    363: long poll_events(int waitkey)
                    364: {
                    365:     int msg[8];
                    366:     int dummy;
                    367:     int which;
                    368:     int key = 0;
                    369:     /* 1/10th second when waiting for key, poll otherwise */
                    370:     unsigned long time = (waitkey ? 100L : 1L);
                    371:
                    372:     do {
                    373:        which = evnt_multi(
                    374:                              (waitkey ? (MU_MESAG | MU_KEYBD | MU_TIMER) : (MU_MESAG | MU_TIMER)),
                    375:                              0, 0, 0,
                    376:                              0, 0, 0, 0, 0,
                    377:                              0, 0, 0, 0, 0,
                    378:                              msg,
                    379: #ifdef __PUREC__
                    380:                              time, 0,
                    381: #else
                    382:                              time,
                    383: #endif
                    384:                              &dummy, &dummy, &dummy, &dummy, &key, &dummy);
                    385:
                    386:        if (which & MU_MESAG) {
                    387:            process_message(msg);
                    388:        }
                    389:     } while (which & MU_MESAG);
                    390:
                    391:     if (which & MU_KEYBD) {
                    392:        return ((Kbshift(-1) & 7) << 24) | ((long) (key & 0xff00) << 8) | (key & 0xff);
                    393:     } else {
                    394:        return 0;
                    395:     }
                    396: }
                    397:
                    398: static void f_line(int x, int y, int w, int h)
                    399: {
                    400:     v_pline(vdi_handle, pxy_index, pxy);
                    401: }
                    402:
                    403: static void flush_line()
                    404: {
                    405:     int line_type;
                    406:     int color_index;
                    407:     int i;
                    408:
                    409:     if (pxy_index >= 2) {
                    410:        if (ATARI_numcolors == 2) {     /* Monochrome */
                    411:            color_index = 1;
                    412:            line_type = ATARI_lt;
                    413:            if (line_type >= 0)
                    414:                line_type %= (ATARI_LINETYPES_MAX - 2);
                    415:        } else {                /* Color */
                    416:            if (ATARI_lt < 0) {
                    417:                color_index = 1;
                    418:                line_type = ATARI_lt;
                    419:            } else {
                    420:                color_index = 2 + ATARI_lt % (ATARI_numcolors - 2);
                    421:                line_type = (ATARI_lt / (ATARI_numcolors - 2)) % (ATARI_LINETYPES_MAX - 2);
                    422:            }
                    423:        }
                    424:
                    425:        vswr_mode(vdi_handle, MD_TRANS);
                    426:        vsl_color(vdi_handle, color_index);
                    427:
                    428:        vsl_type(vdi_handle, 7);
                    429:        vsl_udsty(vdi_handle, ATARI_linetypes[line_type + 2]);
                    430:        walk_rects(f_line, win_xpos, win_ypos, win_xsize, win_ysize);
                    431:     }
                    432:     if (pxy_index >= 1) {
                    433:        pxy[0] = pxy[2 * (pxy_index - 1)];
                    434:        pxy[1] = pxy[2 * (pxy_index - 1) + 1];
                    435:        pxy_index = 1;
                    436:     }
                    437: }
                    438:
                    439: static void put_text(int x, int y, int w, int h)
                    440: {
                    441:     v_gtext(vdi_handle, put_text_x, put_text_y, put_text_str);
                    442: }
                    443:
                    444: TERM_PUBLIC void ATARI_options()
                    445: {
                    446: #define ATARIHEXERROR "palette values 3 hex digits, please"
                    447: #define ATARIHEIGHTERROR "expecting a character height"
                    448:     char opt[6];               /* maximum: 'fff'\0 */
                    449:     int i;
                    450:     char *tok_end;
                    451:
                    452:     term_options[0] = NUL;
                    453:     ATARI_c_height = ATARI_c_height_default;
                    454:
                    455:     for (i = 0; i < 17; i++) {
                    456:        if (END_OF_COMMAND)
                    457:            break;
                    458:        if (token[c_token].length > 5) {
                    459:            ATARI_numpalette = 0;
                    460:            ATARI_c_height = ATARI_c_height_default;
                    461:            term_options[0] = NUL;
                    462:            int_error(ATARIHEXERROR, c_token);
                    463:        }
                    464:        capture(opt, c_token, c_token, 6);
                    465:        if (!i) {
                    466:            ATARI_c_height = strtoul(opt, &tok_end, 10);
                    467:            if (*tok_end != NUL) {
                    468:                ATARI_numpalette = 0;
                    469:                ATARI_c_height = ATARI_c_height_default;
                    470:                term_options[0] = NUL;
                    471:                int_error(ATARIHEIGHTERROR, c_token);
                    472:            }
                    473:            if (ATARI_c_height > 999)
                    474:                ATARI_c_height = 999;   /* avoid opt length overflow */
                    475:            sprintf(opt, "%d ", ATARI_c_height);
                    476:        } else {
                    477:            if (*opt == '"' || *opt == '\'') {
                    478:                opt[strlen(opt) - 1] = NUL;
                    479:                strcpy(opt, opt + 1);
                    480:            }
                    481:            ATARI_colors[i - 1] = strtoul(opt, &tok_end, 16);
                    482:            if (*tok_end != NUL) {
                    483:                ATARI_numpalette = 0;
                    484:                ATARI_c_height = ATARI_c_height_default;
                    485:                term_options[0] = NUL;
                    486:                int_error(ATARIHEXERROR, c_token);
                    487:            }
                    488:            sprintf(opt, "%X ", ATARI_colors[i - 1]);
                    489:
                    490:            /* do we need to quote? */
                    491:            if (isdigit(*opt) && strpbrk(opt, "ABCDEF")) {
                    492:                sprintf(opt, "\"%X\" ", ATARI_colors[i - 1]);
                    493:            }
                    494:        }
                    495:        strcat(term_options, opt);
                    496:        c_token++;
                    497:     }
                    498:     ATARI_numpalette = (i == 0 ? 0 : i - 1);
                    499:     /* printf("Number of linetypes:%d\n", ATARI_LINETYPES_MAX); */
                    500: }
                    501:
                    502: TERM_PUBLIC void ATARI_init()
                    503: {
                    504:     int work_in[11];
                    505:     int work_out[57];
                    506:     int i;
                    507:     int hchar, wchar, dummy;
                    508:     int rgb[3];
                    509:     int num_save;
                    510:     char *colors, *tok_end;
                    511:     int x, y, w, h;
                    512:     static int have_win_size = 0;
                    513:
                    514:     application_init();
                    515:
                    516:     if (ATARI_numpalette == 0 && (colors = getenv("GNUCOLORS")) && *colors) {
                    517:        for (i = 0; i < 17; i++) {
                    518:            if (!i) {
                    519:                ATARI_c_height = strtoul(colors, &tok_end, 10);
                    520:                if (colors == tok_end) {
                    521:                    i = 0;
                    522:                    ATARI_c_height = ATARI_c_height_default;
                    523:                    break;
                    524:                }
                    525:            } else {
                    526:                if (*colors == '\0')
                    527:                    break;
                    528:                ATARI_colors[i] = strtoul(colors, &tok_end, 16);
                    529:                if (colors == tok_end || (unsigned) ATARI_colors[i] > 0xfff) {
                    530:                    i = 0;
                    531:                    break;
                    532:                }
                    533:            }
                    534:            colors = tok_end;
                    535:
                    536:            while (*colors == ' ')
                    537:                colors++;
                    538:        }
                    539:        ATARI_numpalette = (i == 0 ? 0 : i - 1);
                    540:     }
                    541:     vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
                    542:
                    543:     if (!vdi_handle)
                    544:        int_error("Fatal error opening virtual workstation", NO_CARET);
                    545:
                    546:     for (i = 0; i < 10; work_in[i++] = 1);
                    547:     work_in[10] = 2;           /* use raster coordinates */
                    548:     v_opnvwk(work_in, &vdi_handle, work_out);
                    549:
                    550:     if (!vdi_handle)
                    551:        int_error("Fatal error opening virtual workstation", NO_CARET);
                    552:
                    553:     if (!have_win_size) {
                    554:        wind_get(0, WF_WORKXYWH, &x, &y, &w, &h);
                    555:        wind_calc(WC_WORK, WINTYPE, x, y, w, h, &win_xpos, &win_ypos,
                    556:                  &win_xsize, &win_ysize);
                    557:        have_win_size = 1;
                    558:     }
                    559:     term->xmax = win_xsize;
                    560:     term->ymax = win_ysize;
                    561:
                    562:     vst_height(vdi_handle, ATARI_c_height, &dummy, &dummy, &wchar, &hchar);
                    563:
                    564:     term->h_char = wchar;
                    565:     term->v_char = hchar;      /* hchar stands for height this time */
                    566:     term->h_tic = win_xsize / 100;
                    567:     term->v_tic = term->h_tic;
                    568:
                    569:     ATARI_maxycoord = win_ysize - 1;
                    570:     ATARI_numcolors = work_out[13];
                    571:
                    572:     for (i = 0; i < ATARI_numpalette; i++) {
                    573:        vq_color(vdi_handle, i, 1, ATARI_savecolors[i]);
                    574:
                    575:        rgb[0] = 1000 * (ATARI_colors[i] >> 8);
                    576:        rgb[0] /= 15;
                    577:        rgb[1] = 1000 * ((ATARI_colors[i] >> 4) & 15);
                    578:        rgb[1] /= 15;
                    579:        rgb[2] = 1000 * (ATARI_colors[i] & 15);
                    580:        rgb[2] /= 15;
                    581:        vs_color(vdi_handle, i, rgb);
                    582:     }
                    583:     pxy_index = 0;
                    584: }
                    585:
                    586: TERM_PUBLIC void ATARI_reset()
                    587: {
                    588:     int i;
                    589:
                    590:     close_window();
                    591:     if (vdi_handle != -1) {
                    592:        for (i = 0; i < ATARI_numpalette; i++) {
                    593:            vs_color(vdi_handle, i, ATARI_savecolors[i]);
                    594:        }
                    595:        v_clsvwk(vdi_handle);
                    596:        vdi_handle = -1;
                    597:     }
                    598: }
                    599:
                    600: TERM_PUBLIC void ATARI_graphics()
                    601: {
                    602:     ATARI_maxycoord = win_ysize - 1;
                    603:
                    604:     term->xmax = win_xsize;
                    605:     term->ymax = win_ysize;
                    606:
                    607:     mouse_mode();
                    608:     open_window();
                    609:     poll_events(0);
                    610:     walk_rects(clear, win_xpos, win_ypos, win_xsize, win_ysize);
                    611:
                    612:     pxy_index = 0;
                    613: }
                    614:
                    615: TERM_PUBLIC void ATARI_text()
                    616: {
                    617:     flush_line();
                    618:     if (!multi_aes) {
                    619:        while (window_id != -1 && !poll_events(1));
                    620:        close_window();
                    621:     }
                    622:     text_mode();
                    623: }
                    624:
                    625: TERM_PUBLIC void ATARI_move(unsigned int x, unsigned int y)
                    626: {
                    627:     flush_line();
                    628:
                    629:     pxy[0] = x + win_xpos;
                    630:     pxy[1] = ATARI_yc(y) + win_ypos;
                    631:     pxy_index = 1;
                    632: }
                    633:
                    634: TERM_PUBLIC void ATARI_vector(unsigned int x, unsigned int y)
                    635: {
                    636:     pxy[2 * pxy_index] = x + win_xpos;
                    637:     pxy[2 * pxy_index + 1] = ATARI_yc(y) + win_ypos;
                    638:     pxy_index++;
                    639:
                    640:     if (pxy_index == 64) {     /* we're all full */
                    641:        flush_line();
                    642:     }
                    643: }
                    644:
                    645: TERM_PUBLIC void ATARI_linetype(int lt)
                    646: {
                    647:     flush_line();
                    648:
                    649:     ATARI_lt = lt;
                    650: }
                    651:
                    652: TERM_PUBLIC void ATARI_put_text(unsigned int x, unsigned int y, char *str)
                    653: {
                    654:     int vchar = term->v_char;
                    655:     int dummy;
                    656:
                    657:     if (!strlen(str))
                    658:        return;
                    659:
                    660:     if (x < 0)
                    661:        x = 0;
                    662:     if (y < 0)
                    663:        y = 0;
                    664:
                    665:     /* align text left and to middle of char height */
                    666:     vst_alignment(vdi_handle, 0, 5, &dummy, &dummy);
                    667:     vst_rotation(vdi_handle, (ATARI_rotation ? 900 : 0));
                    668:     if (ATARI_rotation) {
                    669:        put_text_x = x - vchar / 2 + 1 + win_xpos;
                    670:        put_text_y = ATARI_yc(y) - 1 + win_ypos;
                    671:        put_text_str = str;
                    672:     } else {
                    673:        put_text_x = x + 1 + win_xpos;
                    674:        put_text_y = ATARI_yc(y) - vchar / 2 + 1 + win_ypos;
                    675:        put_text_str = str;
                    676:     }
                    677:     walk_rects(put_text, win_xpos, win_ypos, win_xsize, win_ysize);
                    678: }
                    679:
                    680: TERM_PUBLIC int ATARI_text_angle(int ang)
                    681: {
                    682:     ATARI_rotation = ang;
                    683:
                    684:     return TRUE;
                    685: }
                    686:
                    687: TERM_PUBLIC int ATARI_justify_text(enum JUSTIFY mode)
                    688: {
                    689:     return FALSE;
                    690: }
                    691:
                    692: TERM_PUBLIC void ATARI_point(unsigned int x, unsigned int y, int number)
                    693: {
                    694:     int old_linetype;
                    695:
                    696:     if (ATARI_numcolors == 2) {
                    697:        line_and_point(x, y, number);   /* monochrome */
                    698:     } else {
                    699:        /* we map colors that exceed our limit to dotted lines, but we can't do
                    700:           that with the markers (sortof a generalized line_and_point) */
                    701:        old_linetype = ATARI_lt;
                    702:        if (ATARI_lt > ATARI_numcolors - 2)
                    703:            ATARI_linetype(ATARI_lt % (ATARI_numcolors - 2));   /* same color, but no dots */
                    704:        do_point(x, y, number);
                    705:        ATARI_linetype(old_linetype);
                    706:     }
                    707: }
                    708:
                    709: #endif /* TERM_BODY */
                    710:
                    711: #ifdef TERM_TABLE
                    712:
                    713: TERM_TABLE_START(atari_driver)
                    714:     "atari", "Atari AES-Terminal",
                    715:     ATARI_XMAX, ATARI_YMAX, ATARI_VCHAR, ATARI_HCHAR,
                    716:     ATARI_VTIC, ATARI_HTIC, ATARI_options, ATARI_init, ATARI_reset,
                    717:     ATARI_text, null_scale, ATARI_graphics, ATARI_move, ATARI_vector,
                    718:     ATARI_linetype, ATARI_put_text, ATARI_text_angle,
                    719:     ATARI_justify_text, ATARI_point, do_arrow, set_font_null,
                    720:     0, TERM_CAN_MULTIPLOT, 0, 0
                    721: TERM_TABLE_END(atari_driver)
                    722:
                    723: #undef LAST_TERM
                    724: #define LAST_TERM atari_driver
                    725:
                    726: #endif /* TERM_TABLE */
                    727:
                    728: #endif /* TERM_PROTO_ONLY */
                    729:
                    730: #ifdef TERM_HELP
                    731: START_HELP(atari)
                    732: "1 atari ST (via AES)",
                    733: "?commands set terminal atari",
                    734: "?set terminal atari",
                    735: "?set term atari",
                    736: "?terminal atari",
                    737: "?term atari",
                    738: "?atari",
                    739: " The `atari` terminal has options to set the character size and the screen",
                    740: " colors.",
                    741: "",
                    742: " Syntax:",
                    743: "       set terminal atari {<fontsize>} {<col0> <col1> ... <col15.}",
                    744: "",
                    745: " The character size must appear if any colors are to be specified.  Each of",
                    746: " the (up to 16) colors is given as a three-digit hex number, where the digits",
                    747: " represent RED, GREEN and BLUE (in that order).  The range of 0--15 is scaled",
                    748: " to whatever color range the screen actually has.  On a normal ST screen, odd",
                    749: " and even intensities are the same.",
                    750: "",
                    751: " Examples:",
                    752: "       set terminal atari 4    # use small (6x6) font",
                    753: "       set terminal atari 6 0  # set monochrome screen to white on black",
                    754: "       set terminal atari 13 0 fff f00 f0 f ff f0f",
                    755: "                  # set first seven colors to black, white, green, blue,",
                    756: "                  # cyan, purple, and yellow and use large font (8x16).",
                    757: "",
                    758: " Additionally, if an environment variable GNUCOLORS exists, its contents are",
                    759: " interpreted as an options string, but an explicit terminal option takes",
                    760: " precedence."
                    761: END_HELP(atari)
                    762: #endif /* TERM_HELP */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>