home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Misc / a2 / Source / cli.c < prev    next >
Encoding:
Text File  |  1992-03-21  |  1.5 KB  |  87 lines

  1. /*
  2.  *  a2, an Apple II emulator in C
  3.  *  (c) Copyright 1990 by Rich Skrenta
  4.  *
  5.  *  Command line interface written by Tom Markson
  6.  *
  7.  *  Distribution agreement:
  8.  *
  9.  *    You may freely copy or redistribute this software, so long
  10.  *    as there is no profit made from its use, sale, trade or
  11.  *    reproduction.  You may not change this copyright notice,
  12.  *    and it must be included prominently in any copy made.
  13.  *
  14.  *  Send emulator related mail to:  skrenta@blekko.commodore.com
  15.  *                    skrenta@blekko.uucp
  16.  */
  17.  
  18.  
  19.  
  20. #import    <stdio.h>
  21. #import    <libc.h>
  22. #import    <setjmp.h>
  23. #import    <signal.h>
  24. #import    "a2.h"
  25. #import    "cli.h"
  26.  
  27.  
  28. FILE *logging_fp = NULL;
  29. long    breakpoint = -1;
  30. long    trace_lo = -1;
  31. long    trace_hi;
  32. int    in_cli;
  33.  
  34. unsigned short lpoint;        /* point where dissassembly occurs */
  35. long phantom_location = -1;
  36. int map_to_upper = 1;
  37. jmp_buf jb;
  38.  
  39. void status(FILE *fp)
  40. {
  41.   diss(Pc, fp);
  42.   flags(fp);
  43. }
  44.  
  45. void cli_catch(int signum)
  46. {
  47.     signal(SIGINT,cli_catch);
  48.     printf("\n");
  49.     longjmp(jb,1);
  50. }
  51.  
  52. void cli(void)
  53. {
  54.     char    foo[200];
  55.  
  56.     restore_term();
  57.     MoveCursor(term_lines, 0);
  58.     status(stdout);
  59.     in_cli = TRUE;
  60.     lpoint = Pc;
  61.     signal(SIGINT, cli_catch);
  62.     setjmp(jb);
  63.     do {
  64.         printf(">>>");
  65.         if (fgets(foo, 200, stdin) == NULL) {
  66.             printf("\n");
  67.             exit(0);
  68.         }
  69.         foo[strlen(foo)-1] = '\0';
  70.         if (parse(first_tbl, foo)) {
  71.             running = FALSE;
  72.             tracing = FALSE;
  73.             return;            /* single step; no redraw */
  74.         }
  75.     } while (in_cli);
  76.  
  77.     set_term();
  78.     redraw_screen();
  79.     if (breakpoint != -1 || trace_lo != -1) {
  80.         tracing = TRUE;
  81.         running = FALSE;
  82.     } else {
  83.         tracing = FALSE;
  84.         running = TRUE;
  85.     }
  86. }
  87.