home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / scase.zip / SCASE.Z / STDIOCTR.CC < prev    next >
C/C++ Source or Header  |  1994-10-17  |  3KB  |  105 lines

  1. /******************************************************************************
  2. *                         ** Company Confidential **
  3. *                  ** Copyright 1994, All rights Reserved **
  4. * %Z%%M% version %I% date:%G%
  5. ******************************************************************************/
  6.  
  7. // -MQBeg- [Module_Includes] [stdioctr_cc] <0000001B.00000000> Retained!
  8. #include "stdio.h"
  9. #include "ttteng.h"
  10. #include "tttdisp.h"
  11. #include "tttcont.h"
  12. #include "stdiodsp.h"
  13. #include "stdioctr.h"
  14. // -MQEnd- [Module_Includes] [stdioctr_cc] <0000001B.00000000> 
  15.  
  16. // -MQBeg- [Module_Declarations_1] [stdioctr_cc] <0000001B.00000000> Retained!
  17. void main()
  18. {
  19.  TTT_Engine     *Engine     = new TTT_Engine;
  20.  TTT_Display    *Display    = new TTT_StdioDisplay(Engine);
  21.  TTT_Controller *Controller = new TTT_StdioController(Engine, Display);
  22.  Controller->Start();
  23.  delete Controller;
  24. }
  25. // -MQEnd- [Module_Declarations_1] [stdioctr_cc] <0000001B.00000000> 
  26.  
  27. // -MQBeg- [Class_Body] [TTT_StdioController] <00000000.00000007> 
  28. /******************************************************************************
  29.                               TTT_StdioController
  30. ******************************************************************************/
  31.  
  32. TTT_StdioController::TTT_StdioController(TTT_Engine *Engine, TTT_Display *Disp)
  33. // -MQBeg- [Op_Init] [TTT_StdioController::TTT_StdioController] <0000002F.0000000F> Retained!
  34.   : TTT_Controller(Engine, Disp)
  35. // -MQEnd- [Op_Init] [TTT_StdioController::TTT_StdioController] <0000002F.0000000F> 
  36. {
  37. // -MQBeg- [Op_Body] [TTT_StdioController::TTT_StdioController] <0000002F.0000000F> Retained!
  38. // -MQEnd- [Op_Body] [TTT_StdioController::TTT_StdioController] <0000002F.0000000F> 
  39. }
  40.  
  41. void
  42. TTT_StdioController::Start()
  43. {
  44. // -MQBeg- [Op_Body] [TTT_StdioController::Start] <0000002F.00000010> Retained!
  45.   TTT_Controller::Start();
  46.  
  47.   int Cell = 0;
  48.   while(1)
  49.   {
  50.     TTT_Controller::TTT_EVENT Event = GetUserEvent(Cell);
  51.     HandleEvent(Event, Cell);
  52.     if (Event == QUIT) break;
  53.   } 
  54. // -MQEnd- [Op_Body] [TTT_StdioController::Start] <0000002F.00000010> 
  55. }
  56.  
  57. TTT_Controller::TTT_EVENT
  58. TTT_StdioController::GetUserEvent(int& Cell)
  59. {
  60. // -MQBeg- [Op_Body] [TTT_StdioController::GetUserEvent] <0000002F.00000011> Retained!
  61.   char inbuf[256];
  62.   TTT_Controller::TTT_EVENT Event = NULL_EVENT;
  63.  
  64.   while ( Event == NULL_EVENT )
  65.   {
  66.     printf("\n   0 | 1 | 2\n  ---+---+---\n   3 | 4 | 5\n  ---+---+---\n   6 | 7 | 8\n");
  67.     printf("<R>eset  <Q>uit\n\n");
  68.     printf("Enter Choice:\n");
  69.  
  70.     gets(inbuf);
  71.  
  72.     switch(inbuf[0])
  73.     {
  74.     case '0':
  75.     case '1':
  76.     case '2':
  77.     case '3':
  78.     case '4':
  79.     case '5':
  80.     case '6':
  81.     case '7':
  82.     case '8':
  83.       Cell  = inbuf[0] - '0';
  84.       Event = MOVE;
  85.       break;
  86.     case 'r':
  87.     case 'R':
  88.       Event = RESET;
  89.       break;
  90.     case 'q':
  91.     case 'Q':
  92.       Event = QUIT;
  93.       break;
  94.     }
  95.   }
  96.  
  97.   return Event;
  98. // -MQEnd- [Op_Body] [TTT_StdioController::GetUserEvent] <0000002F.00000011> 
  99. }
  100.  
  101. // -MQEnd- [Class_Body] [TTT_StdioController] <00000000.00000007> 
  102.  
  103. // -MQBeg- [Module_Declarations_2] [stdioctr_cc] <0000001B.00000000> Retained!
  104. // -MQEnd- [Module_Declarations_2] [stdioctr_cc] <0000001B.00000000> 
  105.