home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GAMES / infocom_src.lha / enhanced.c < prev    next >
Text File  |  1993-03-03  |  3KB  |  152 lines

  1. /*
  2. **    File:    enhanced.c
  3. **
  4. **    (C)opyright 1987-1992 InfoTaskforce.
  5. */
  6.  
  7. #include    <stdio.h>
  8. #include    "infocom.h"
  9.  
  10. /*
  11. **    Enhanced Windowing and Screen Printing Functions.
  12. */
  13.  
  14. Void
  15. set_current_window ( the_window )
  16. word    the_window ;
  17. {
  18.     extern header    data_head ;
  19.     extern word        top_screen_line ;
  20.     extern word        current_window ;
  21.     extern boolean    disable_script ;
  22.  
  23.     if ( data_head.z_code_version >= VERSION_5 )
  24.         flush_prt_buff () ;
  25.     current_window = the_window ;
  26.     if ( the_window != 0 )
  27.     {
  28.         /*
  29.         **    Use the Upper Window.
  30.         */
  31.         
  32.         USE_WINDOW ( WINDOW_1 ) ;
  33.         disable_script = TRUE ;
  34.         save_cursor_position () ;
  35.  
  36.         /*
  37.         **    Move the cursor to the top left-hand corner of the screen.
  38.         */
  39.  
  40.         GOTO_XY ( 0,top_screen_line ) ;
  41.     }
  42.     else
  43.     {
  44.         /*
  45.         **    Use the Lower Window.
  46.         */
  47.         
  48.         USE_WINDOW ( WINDOW_0 ) ;
  49.         disable_script = FALSE ;
  50.         restore_cursor_position () ;
  51.  
  52.         /*
  53.         **    Turn off all text attributes.
  54.         **
  55.         **    Prior to VERSION_4, the "set_text_mode ()" function
  56.         **    did not exist. In VERSION_3 of the interpreter the
  57.         **    statement:
  58.         **                            print_char ( (word)1 ) ;
  59.         **    was used instead of:
  60.         **                            set_text_mode ( (word)0 ) ;
  61.         */
  62.  
  63.         set_text_mode ( (word)0 ) ;
  64.     }
  65. }
  66.  
  67. Void
  68. split_screen ( param )
  69. word    param ;
  70. {
  71.     extern header    data_head ;
  72.     extern boolean    windowing_enabled ;
  73.     extern word        top_screen_line ;
  74.     extern word        window_height ;
  75.     extern int        screen_height ;
  76.     extern int        linecount ;
  77.     
  78.     if ( param == 0 )
  79.     {
  80.         /*
  81.         **    Use the entire Screen.
  82.         */
  83.         
  84.         USE_WINDOW ( FULL_SCREEN ) ;
  85.         restore_cursor_position () ;
  86.         windowing_enabled = FALSE ;
  87.         window_height = 0 ;
  88.         linecount = 0 ;
  89.     }
  90.     else
  91.     {
  92.         windowing_enabled = TRUE ;
  93.         if ( param >= (word)screen_height )
  94.             param = (word)screen_height - 1 ;
  95.         window_height = param ;
  96.         if ( data_head.z_code_version <= VERSION_3 )
  97.         {
  98.             save_cursor_position () ;
  99.             ERASE_WINDOW ( top_screen_line,top_screen_line + param ) ;
  100.             restore_cursor_position () ;
  101.         }
  102.         USE_WINDOW ( WINDOW_0 ) ;
  103.         if ( data_head.z_code_version >= VERSION_5 )
  104.             GOTO_XY ( 0,screen_height - 1 ) ;
  105.     }
  106. }
  107.  
  108. /*
  109. **    Enhanced Windowing Support Routines.
  110. */
  111.  
  112. boolean        cursor_pos_saved        = FALSE ;
  113.  
  114. Void
  115. save_cursor_position ()
  116. {
  117.     extern boolean    cursor_pos_saved ;
  118.  
  119.     if ( cursor_pos_saved == FALSE )
  120.     {
  121.         SAVE_CURSOR () ;
  122.         cursor_pos_saved = TRUE ;
  123.     }
  124. }
  125.  
  126. Void
  127. restore_cursor_position ()
  128. {
  129.     extern header    data_head ;
  130.     extern boolean    cursor_pos_saved ;
  131.     extern int        screen_height ;
  132.  
  133.     if ( data_head.z_code_version <= VERSION_4 )
  134.     {
  135.         if ( cursor_pos_saved != FALSE )
  136.         {
  137.             RESTORE_CURSOR () ;
  138.             cursor_pos_saved = FALSE ;
  139.         }
  140.     }
  141.     else
  142.     {
  143.         if ( cursor_pos_saved != FALSE )
  144.         {
  145.             RESTORE_CURSOR () ;
  146.             cursor_pos_saved = FALSE ;
  147.         }
  148.         else
  149.             GOTO_XY ( 0,screen_height - 1 ) ;
  150.     }
  151. }
  152.