home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / biology / gsrc208a.zip / PMU.C < prev    next >
C/C++ Source or Header  |  1992-12-06  |  3KB  |  153 lines

  1. #include "copyleft.h"
  2.  
  3. /*
  4.     GEPASI - a simulator of metabolic pathways and other dynamical systems
  5.     Copyright (C) 1989, 1992  Pedro Mendes
  6. */
  7.  
  8. /*************************************/
  9. /*                                   */
  10. /*    several utilities including    */
  11. /*    low-level stuff for MS-DOS     */
  12. /*                                   */
  13. /*          MICROSOFT C 6.00         */
  14. /*           QuickC/WIN 1.0          */
  15. /*             ULTRIX cc             */
  16. /*              GNU gcc              */
  17. /*                                   */
  18. /*   (include here compilers that    */
  19. /*   compiled GEPASI successfully)   */
  20. /*                                   */
  21. /*************************************/
  22.  
  23.  
  24. #ifndef MSDOS
  25. #define COMMON
  26. #endif
  27.  
  28. #ifdef _WINDOWS
  29. #define COMMON
  30. #endif
  31.  
  32. #include <stdio.h>
  33. #include <string.h>
  34. #include <time.h>
  35.  
  36. #ifndef COMMON                          /* is this MS-DOS ?    */
  37.  #include <dos.h>
  38.  #include <conio.h>
  39.  #if (_MSC_VER >= 610)                    /* QuickC/WIN and C/C++ 7.0 */
  40.   #define REGS _REGS
  41.   #define getch _getch
  42.   #define kbhit _kbhit
  43.   #define int86 _int86
  44.  #endif
  45. #endif
  46.  
  47. /* stops processing for a specified number of seconds */
  48. void sdelay(unsigned int seconds)
  49. {
  50.    time_t dtime;
  51.  
  52.    dtime = time(NULL) + seconds;
  53.    while (dtime != time(NULL));
  54. }
  55.  
  56. /* sets an extension for a pathname string.   */
  57. /* can also be used on other types of strings */
  58. /* appends *ext to *ss at the last look_for   */
  59.  
  60. void fixext(char *ss, char look_for, char *ext)
  61. {
  62.  char *p;
  63.  
  64.  if ( p = strrchr( ss, look_for ) ) strcpy( p, ext );
  65.  else strcat(ss,ext);
  66. }
  67.  
  68.  
  69. /* sends a BELL to stderr */
  70.  
  71. void beep( void )
  72. {
  73.  fprintf( stderr, "\07" );
  74. }
  75.  
  76.  
  77. #ifdef COMMON  /* non MS-DOS */
  78.  
  79. /*
  80.   we don't know how to clear the screen,
  81.   so let's just send a carriage-return
  82. */
  83. void cls( void )
  84. {
  85.  printf( "\n" );
  86. }
  87.  
  88. /*
  89.   for the following two we just return
  90. */
  91.  
  92. void set_cursor(int x, int y){ }
  93. void get_cursor(int *x, int *y){ }
  94.  
  95. #else    /* good old MS-DOS! */
  96.  
  97. /*
  98.   with a few low-level tricks we clear the screen !
  99. */
  100. void cls(void)
  101. {
  102.    union REGS inregs;
  103.    union REGS outregs;
  104.  
  105.    inregs.h.ah = 15;                    /* get active display page */
  106.    int86(0x10,&inregs,&outregs);
  107.    inregs.h.bh = outregs.h.bh;
  108.    inregs.h.dl = 0;
  109.    inregs.h.dh = 0;
  110.    inregs.h.ah = 2;                     /* set cursor position */
  111.    int86(0x10,&inregs,&outregs);
  112.    inregs.h.bh = 0x07;
  113.    inregs.h.cl = 0;
  114.    inregs.h.ch = 0;
  115.    inregs.h.dl = 79;
  116.    inregs.h.dh = 24;
  117.    inregs.h.al = 0;
  118.    inregs.h.ah = 7;                     /* do the backscroll */
  119.    int86(0x10,&inregs,&outregs);
  120. }
  121.  
  122. /*
  123.   more low-level to set the cursor position...
  124. */
  125. void set_cursor(int x, int y)
  126. {
  127.  union REGS regs;
  128.  
  129.  regs.h.ah  =  2;
  130.  regs.h.dh  =  (unsigned char) y;
  131.  regs.h.dl  =  (unsigned char) x;
  132.  regs.h.bh  =  0;
  133.  int86(0x10,®s,®s);
  134. }
  135.  
  136. /*
  137.   and get the cursor position.
  138. */
  139. void get_cursor(int *x, int *y)
  140. {
  141.  union REGS inregs;
  142.  union REGS outregs;
  143.  
  144.  inregs.h.ah  =  3;
  145.  inregs.h.bh  =  0;
  146.  int86(0x10,&inregs,&outregs);
  147.  *y = outregs.h.dh;
  148.  *x = outregs.h.dl;
  149. }
  150.  
  151. #endif
  152.  
  153.