home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / CROSSASM / 68ASMSIM.ZIP / simsrc / iobox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-09  |  3.8 KB  |  167 lines

  1.  
  2. /***************************** 68000 SIMULATOR ****************************
  3.  
  4. File Name: IOBOX.C
  5. Version: 1.0
  6.  
  7. This file contains system-dependent calls to manipulate the screen.
  8.  
  9. ***************************************************************************/
  10.  
  11.  
  12.  
  13. #include <stdio.h>
  14. #include <conio.h>
  15. #include <dos.h>
  16. #include "extern.h"
  17.  
  18.  
  19. union REGS regs;
  20. int    row, col;
  21.  
  22.  
  23. at(y,x)         /* position cursor at line y (y=1..25), column x (x=1..80) */
  24. int x,y;
  25. {
  26.  
  27.     regs.h.ah = 2;                /* function 2 is cursor position function */
  28.     regs.h.bh = 0;
  29.     regs.h.dh = (y - 1) & 0xff;
  30.     regs.h.dl = (x - 1) & 0xff;
  31.     int86 (0x10, ®s, ®s);
  32.     return (regs.x.cflag);
  33.  
  34. }
  35.  
  36.  
  37.  
  38. home()
  39. {
  40.  
  41.     at(1,1);
  42.     return SUCCESS;
  43.  
  44. }
  45.  
  46.  
  47.  
  48. int    clrscr()            /* clear screen by using bios scroll up function */
  49. {
  50.  
  51.     regs.h.ah = 6;            /* function 6 is scroll-up */
  52.     regs.h.al = 0;            /* entire screen */
  53.     regs.h.bh = 0x2007;    /* use attribute 0x2007 */
  54.     regs.h.bl = 0;
  55.     regs.x.cx = 0;
  56.     regs.h.dh = 24;        /* number of rows - 1 */
  57.     regs.h.dl = 79;        /* number of columns - 1 */
  58.     int86 (0x10, ®s, ®s);
  59.  
  60.     return (regs.x.cflag);
  61.  
  62. }
  63.  
  64.  
  65. char chk_buf()                /* read a character from the keyboard buffer */
  66.                                        /* return '\0' if nothing available */
  67. {
  68.  
  69.     if (kbhit())
  70.         return (bdos(0x07) & 0x00ff);
  71.     else
  72.         return ('\0');
  73.  
  74. }
  75.  
  76.  
  77. /* function windowLine() gives a newline within the scrollable window */
  78.  
  79. void    windowLine()
  80. {
  81.  
  82.     regs.h.ah = 3;                            /* function 3 = read cursor position */
  83.     regs.h.bh = 0;                            /* page 0 */
  84.     int86 (0x10, ®s, ®s);
  85.     if (regs.h.dh < 23) {
  86.         printf ("\n");                        /* regular newline */
  87.         return ;
  88.         }
  89.  
  90.     regs.h.ah = 6;                            /* function 6 = scroll screen */
  91.     regs.h.al = 1;                            /* scroll 1 line */
  92.     regs.h.bh = 0x07;                        /* new line display attribute */
  93.     regs.h.ch = 8;                            /* start at line 8 */
  94.     regs.h.cl = 0;                            /* "     "  column 0 */
  95.     regs.h.dh = 24;                        /* end at line 24 */
  96.     regs.h.dl = 79;                        /* "   "  column 79 */
  97.  
  98.     int86 (0x10, ®s, ®s);        /* call video services BIOS function */
  99.  
  100.     regs.h.ah = 2;                            /* set cursor position */
  101.     regs.h.bh = 0;                            /* page 0 */
  102.     regs.h.dh = 23;                        /* row 24 */
  103.     regs.h.dl = 0;                            /* column 0 */
  104.  
  105.     int86 (0x10, ®s, ®s);        /* call video services BIOS function */
  106.  
  107. }
  108.  
  109.  
  110. /* function scrollWindow() scrolls the scrolling window up if the text has */
  111. /* moved down to line 25.  This function is called after the user enters */
  112. /* information within the scrolling portion of the screen */
  113.  
  114. void    scrollWindow()
  115. {
  116.  
  117.     regs.h.ah = 3;                            /* function 3 = read cursor position */
  118.     regs.h.bh = 0;                            /* page 0 */
  119.     int86 (0x10, ®s, ®s);
  120.     if (regs.h.dh >= 24) {
  121.         regs.h.ah = 6;                            /* function 6 = scroll screen */
  122.         regs.h.al = 1;                            /* scroll 1 line */
  123.         regs.h.bh = 0x07;                        /* new line display attribute */
  124.         regs.h.ch = 8;                            /* start at line 8 */
  125.         regs.h.cl = 0;                            /* "     "  column 0 */
  126.         regs.h.dh = 24;                        /* end at line 24 */
  127.         regs.h.dl = 79;                        /* "   "  column 79 */
  128.  
  129.         int86 (0x10, ®s, ®s);        /* call video services BIOS function */
  130.  
  131.         regs.h.ah = 2;                            /* set cursor position */
  132.         regs.h.bh = 0;                            /* page 0 */
  133.         regs.h.dh = 23;                        /* row 24 */
  134.         regs.h.dl = 0;                            /* column 0 */
  135.  
  136.         int86 (0x10, ®s, ®s);        /* call video services BIOS function */
  137.         }
  138.  
  139. }
  140.  
  141.  
  142. void    save_cursor()
  143. {
  144.  
  145.     regs.h.ah = 3;                            /* function 3 = read cursor position */
  146.     regs.h.bh = 0;                            /* page 0 */
  147.     int86 (0x10, ®s, ®s);
  148.     row = regs.h.dh;
  149.     col = regs.h.dl;
  150.  
  151. }
  152.  
  153.  
  154. void    restore_cursor()
  155. {
  156.  
  157.     regs.h.ah = 2;                            /* set cursor position */
  158.     regs.h.bh = 0;                            /* page 0 */
  159.     regs.h.dh = row;                        /* row */
  160.     regs.h.dl = col;                        /* column */
  161.  
  162.     int86 (0x10, ®s, ®s);        /* call video services BIOS function */
  163.  
  164. }
  165.  
  166.  
  167.