home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / MSWSRC35 / IBMTERM.CPP < prev    next >
C/C++ Source or Header  |  1993-08-19  |  5KB  |  287 lines

  1. /*
  2.  *      ibmterm.c           IBM screen module             mak
  3.  *
  4.  *    Copyright (C) 1989 The Regents of the University of California
  5.  *    This Software may be copied and distributed for educational,
  6.  *    research, and not for profit purposes provided that this
  7.  *    copyright and statement are included in all such copies.
  8.  *
  9.  */
  10.  
  11. #include "logo.h"
  12. #include "globals.h"
  13. #include <math.h>
  14. #include <bios.h>
  15. #include <conio.h>
  16.  
  17. //fake defs
  18. #define COPY_PUT 12
  19. //
  20.  
  21. extern x_margin, y_margin;
  22. /************************************************************/
  23.  
  24. //extern unsigned _stklen = 8000; /* 5000 for debugging, 65000 for real */
  25.  
  26. BOOLEAN in_graphics_mode = FALSE;
  27. BOOLEAN have_been_in_graphics_mode = FALSE;
  28. BOOLEAN in_erase_mode = FALSE;
  29.  
  30. int ibm_screen_top, ibm_turtle_top_max;
  31. int current_write_mode = COPY_PUT;
  32. int current_vis = 0;
  33. int turtle_color;
  34. int prev_color;
  35. int texth;
  36. extern int MaxX, MaxY;
  37. void *window_image;
  38.  
  39. void nop()
  40. {
  41. }
  42.  
  43. BOOLEAN check_ibm_stop()
  44. {
  45. //    long base, top;
  46. //    int key;
  47.  
  48. //    Time_To_Pause = 0;
  49. //    Time_To_Halt = 0;
  50.  
  51.     MyMessageScan();
  52.  
  53.     if (Time_To_Halt)
  54.       {
  55.         Time_To_Halt = 0;
  56.         emptyqueue();
  57.     err_logo(STOP_ERROR,NIL);
  58.     return(1);
  59.       }
  60.     if (Time_To_Pause)
  61.       {
  62.         Time_To_Pause = 0;
  63.     to_pending = 0;
  64.     lpause();
  65.       }
  66.     return (0);
  67. }
  68.  
  69. void term_init_ibm()
  70. {
  71.     tty_charmode = 0;
  72.     x_max = 80;
  73.     y_max = 24;
  74.     x_coord = y_coord = 0;
  75. /*
  76.     so_arr[0] = '\1'; so_arr[1] = '\0';
  77.     se_arr[0] = '\2'; se_arr[1] = '\0';
  78. */
  79. }
  80.  
  81. void ibm_gotoxy(int x, int y)
  82. {
  83.     gotoxy(x + 1, y + 1);
  84. }
  85.  
  86. void ibm_clear_text()
  87. {
  88.     clearcombobox();
  89. }
  90.  
  91. char oldattr = 7; /* assume gray on black */
  92.  
  93. void ibm_plain_mode()
  94. {
  95. //    textattr(oldattr); /* white on black */
  96. }
  97.  
  98. /************************************************************/
  99. /* These are the machine-specific graphics definitions.  All versions must
  100.    provide a set of functions analogous to these. */
  101.  
  102. void save_pen(pen_info *p)
  103. {
  104. //    p->h = getx();
  105. //    p->v = gety();
  106.     p->vis = current_vis;
  107.     p->width = get_ibm_pen_width();
  108. //    p->color = getcolor();
  109.     p->prev_color = prev_color;
  110.     get_pen_pattern(p->pattern);
  111.     p->mode = get_ibm_pen_mode();
  112. }
  113.  
  114. void restore_pen(pen_info *p)
  115. {
  116. //    moveto(p->h, p->v);
  117.     current_vis = p->vis;
  118.     set_ibm_pen_width(p->width);
  119.     set_ibm_pen_mode(p->mode);  /* must restore mode before color */
  120. //    setcolor(p->color);
  121.     prev_color = p->prev_color;
  122.     set_pen_pattern(p->pattern);
  123. }
  124.  
  125. void plain_xor_pen()
  126. {
  127.     set_ibm_pen_width(1);
  128. //    setcolor(turtle_color);
  129. //    setwritemode(XOR_PUT);
  130.     current_write_mode = XOR_PUT;
  131.     in_erase_mode = FALSE;
  132. }
  133.  
  134. void ibm_pen_down()
  135. {
  136. //    setwritemode(COPY_PUT);
  137.     current_write_mode = COPY_PUT;
  138.     if (in_erase_mode) {
  139. //    setcolor(prev_color);
  140.     in_erase_mode = FALSE;
  141.     }
  142. }
  143.  
  144. void ibm_pen_xor()
  145. {
  146. //    setwritemode(XOR_PUT);
  147.     current_write_mode = XOR_PUT;
  148.     if (in_erase_mode) {
  149. //    setcolor(prev_color);
  150.     in_erase_mode = FALSE;
  151.     }
  152. }
  153.  
  154. void ibm_pen_erase()
  155. {
  156.     if (!in_erase_mode) {
  157. //    setwritemode(COPY_PUT);
  158.     current_write_mode = COPY_PUT;
  159. //    prev_color = getcolor();
  160. //    setcolor(0);
  161.     in_erase_mode = TRUE;
  162.     }
  163. }
  164.  
  165. int get_ibm_pen_mode()
  166. {
  167.     if (in_erase_mode)
  168.     return 2;
  169.     else
  170.     return current_write_mode;
  171. }
  172.  
  173. void set_ibm_pen_mode(int m)
  174. {
  175.     switch (m) {
  176.     case 2: ibm_pen_erase(); break;
  177.     case COPY_PUT: ibm_pen_down(); break;
  178.     case XOR_PUT: ibm_pen_xor(); break;
  179.     }
  180. }
  181.  
  182. //int get_ibm_pen_width()
  183. //{
  184. //    struct linesettingstype ls;
  185. //
  186. //    getlinesettings(&ls);
  187. //    return ls.thickness;
  188. //return (0);
  189. //}
  190.  
  191. void set_pen_pattern(char *pat)
  192. {
  193. //    setfillpattern(pat, getcolor());
  194. }
  195.  
  196. void set_list_pen_pattern(NODE *arg)
  197. {
  198.     unsigned char pat[8];
  199.     NODE *cur_num, *temp;
  200.     int count;
  201.  
  202.     cur_num = arg;
  203.     for (count = 0 ; count <= 7 ; count++) {
  204.     temp = cnv_node_to_numnode(car(cur_num));
  205.     pat[count] = (char)getint(temp);
  206.     if (cdr(cur_num) != NIL)
  207.         cur_num = cdr(cur_num);
  208.     gcref(temp);
  209.     }
  210. //    setfillpattern(pat, getcolor());
  211. }
  212.  
  213. void get_pen_pattern(char *pat)
  214. {
  215. //    getfillpattern(pat);
  216. }
  217.  
  218. NODE *Get_node_pen_pattern()
  219. {
  220.     unsigned char pat[8];
  221.  
  222. /*
  223.     getfillpattern(pat);
  224.     return(cons(make_intnode((FIXNUM)(pat[0])),
  225.         cons(make_intnode((FIXNUM)(pat[1])),
  226.          cons(make_intnode((FIXNUM)(pat[2])),
  227.           cons(make_intnode((FIXNUM)(pat[3])),
  228.            cons(make_intnode((FIXNUM)(pat[4])),
  229.         cons(make_intnode((FIXNUM)(pat[5])),
  230.          cons(make_intnode((FIXNUM)(pat[6])),
  231.           cons(make_intnode((FIXNUM)(pat[7])),
  232.            NIL)))))))));
  233. */
  234. return(NIL);
  235. }
  236.  
  237. NODE *Get_node_pen_mode()
  238. {
  239.     if (in_erase_mode)
  240.     return(make_static_strnode("erase"));
  241.     if (current_write_mode == XOR_PUT)
  242.     return(make_static_strnode("reverse"));
  243.     return(make_static_strnode("paint"));
  244. }
  245.  
  246. void erase_screen()
  247. {
  248.     ibm_clear_screen();
  249. }
  250.  
  251. FIXNUM mickey_x()
  252. {
  253.     return 0;
  254. }
  255.  
  256. FIXNUM mickey_y()
  257. {
  258.     return 0;
  259. }
  260.  
  261. BOOLEAN Button()
  262. {
  263.     return FALSE;
  264. }
  265.  
  266. void tone(FIXNUM pitch, FIXNUM duration)
  267. {
  268. //    sound(pitch);
  269. //    delay(duration);
  270. //    nosound();
  271. }
  272.  
  273. FIXNUM t_height()
  274. {
  275.     return 18;
  276. }
  277.  
  278. FLONUM t_half_bottom()
  279. {
  280.     return 6.0;
  281. }
  282.  
  283. FLONUM t_side()
  284. {
  285.     return 19.0;
  286. }
  287.