home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / z80sim / simfun.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-11  |  1.6 KB  |  84 lines

  1. /*
  2.  * Z80SIM  -  a    Z80-CPU    simulator
  3.  *
  4.  * Copyright (C) 1987-92 by Udo Munk
  5.  *
  6.  * This module of the Z80-CPU simulator must not be modified by a user,
  7.  * see license agreement!
  8.  *
  9.  * History:
  10.  * 28-SEP-87 Development on TARGON/35 with AT&T Unix System V.3
  11.  * 11-JAN-89 Release 1.1
  12.  * 08-FEB-89 Release 1.2
  13.  * 13-MAR-89 Release 1.3
  14.  * 09-FEB-90 Release 1.4 Ported to TARGON/31 M10/30
  15.  * 20-DEC-90 Release 1.5 Ported to COHERENT 3.0
  16.  * 10-JUN-92 Release 1.6 long casting problem solved with COHERENT 3.2
  17.  *             and some optimization
  18.  * 25-JUN-92 Release 1.7 comments in english and ported to COHERENT 4.0
  19.  */
  20.  
  21. /*
  22.  *    This modul contains some commonly used functions
  23.  */
  24.  
  25. #include <ctype.h>
  26. #if defined(COHERENT) && !defined(_I386)
  27. #include <sgtty.h>
  28. #else
  29. #include <termio.h>
  30. #endif
  31. #include "sim.h"
  32.  
  33. /*
  34.  *    atoi for hexadecimal numbers
  35.  */
  36. exatoi(str)
  37. register char *str;
  38. {
  39.     register int num = 0;
  40.  
  41.     while (isxdigit(*str)) {
  42.         num *= 16;
  43.         if (*str <= '9')
  44.             num += *str - '0';
  45.         else
  46.             num += toupper(*str) - '7';
  47.         str++;
  48.     }
  49.     return(num);
  50. }
  51.  
  52. /*
  53.  *    Wait for a single keystroke without echo
  54.  */
  55. getkey()
  56. {
  57.     register int c;
  58. #if defined(COHERENT) && !defined(_I386)
  59.     struct sgttyb old_term,    new_term;
  60. #else
  61.     struct termio old_term, new_term;
  62. #endif
  63.  
  64. #if defined(COHERENT) && !defined(_I386)
  65.     gtty(0, &old_term);
  66.     new_term = old_term;
  67.     new_term.sg_flags |= CBREAK;
  68.     new_term.sg_flags &= ~ECHO;
  69.     stty(0, &new_term);
  70. #else
  71.     ioctl(0, TCGETA, &old_term);
  72.     new_term = old_term;
  73.     new_term.c_lflag &= ~(ICANON | ECHO);
  74.     new_term.c_cc[4] = 1;
  75. #endif
  76.     c = getchar();
  77. #if defined(COHERENT) && !defined(_I386)
  78.     stty(0, &old_term);
  79. #else
  80.     ioctl(0, TCSETAW, &old_term);
  81. #endif
  82.     return(c);
  83. }
  84.