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

  1. /*
  2. **    File:    status.c
  3. **
  4. **    (C)opyright 1987-1992 InfoTaskforce.
  5. */
  6.  
  7. #include    "infocom.h"
  8.  
  9. /*
  10. **    Status-Bar Routine Variables.
  11. **
  12. **    Note:
  13. **        The variable "s_buff_ptr" is of type "byte *"
  14. **        NOT "byte_ptr" - these definitions are
  15. **        different for MSDOS Compilers ("byte_ptr" is huge).
  16. */
  17.  
  18. byte            s_buffer[MAX_LINE_LENGTH] ;
  19. byte            *s_buff_ptr ;
  20. static char        *score_str    = "Score: " ;
  21. static char        *time_str    = "Time:  " ;
  22.  
  23. Void
  24. put_status ( ch )
  25. word    ch ;
  26. {
  27.     *s_buff_ptr++ = (byte)ch ;
  28. }
  29.  
  30. char
  31. *copy_string ( src,dst )
  32. char    *src ;
  33. char    *dst ;
  34. {
  35.     while ( *src != '\0' )
  36.         *dst++ = *src++ ;
  37.     return ( dst ) ;
  38. }
  39.  
  40. Void
  41. prt_status ()
  42. {
  43.     extern header    data_head ;
  44.     extern boolean    disable_script ;
  45.     extern proc_ptr    PrintChar ;
  46.     extern int        screen_width ;
  47.  
  48.     word            hour ;
  49.     word            minutes ;
  50.     char            ch ;
  51.     boolean            old_disable_script ;
  52.     proc_ptr        old_procptr ;
  53.  
  54.     s_buff_ptr = s_buffer ;
  55.     *s_buff_ptr++ = ' ' ;
  56.     old_disable_script = disable_script ;
  57.     disable_script = TRUE ;
  58.     old_procptr = PrintChar ;
  59.     PrintChar = put_status ;
  60.  
  61.     std_p_obj ( load_var ( 0x10 ) ) ;
  62.  
  63.     if (( data_head.mode_bits & USE_TIME ) == 0 )
  64.     {
  65.         while ( s_buff_ptr < ( s_buffer + screen_width - 0x14 ) )
  66.             *s_buff_ptr++ = ' ' ;
  67.         s_buff_ptr = (byte *)copy_string ( score_str,(char *)s_buff_ptr ) ;
  68.         print_num ( load_var ( 0x11 ) ) ;
  69.         *s_buff_ptr++ = '/' ;
  70.         print_num ( load_var ( 0x12 ) ) ;
  71.     }
  72.     else
  73.     {
  74.         while ( s_buff_ptr < ( s_buffer + screen_width - 0x10 ) )
  75.             *s_buff_ptr++ = ' ' ;
  76.         s_buff_ptr = (byte *)copy_string ( time_str,(char *)s_buff_ptr ) ;
  77.         hour = load_var ( 0x11 ) ;
  78.  
  79.         /*
  80.         **    Convert 24 hour time to AM/PM
  81.         */
  82.  
  83.         ch = 'A' ;
  84.         if ( hour >= 12 )
  85.         {
  86.             hour -= 12 ;
  87.             ch = 'P' ;
  88.         }
  89.         if ( hour == 0 )
  90.             hour = 12 ;
  91.  
  92.         /*
  93.         **    Print Time
  94.         */
  95.  
  96.         print_num ( hour ) ;
  97.         *s_buff_ptr++ = ':' ;
  98.  
  99.         /*
  100.         **    Can't use print_num for minutes since we want leading zeros
  101.         */
  102.  
  103.         minutes = load_var ( 0x12 ) ;
  104.         *s_buff_ptr++ = ((minutes / 10) + '0') ;
  105.         *s_buff_ptr++ = ((minutes % 10) + '0') ;
  106.         *s_buff_ptr++ = ' ' ;
  107.         *s_buff_ptr++ = ch ;
  108.         *s_buff_ptr++ = 'M' ;
  109.     }
  110.     while ( s_buff_ptr < ( s_buffer + screen_width ) )
  111.         *s_buff_ptr++ = ' ' ;
  112.     print_status ( s_buffer ) ;
  113.     disable_script = old_disable_script ;
  114.     PrintChar = old_procptr ;
  115. }
  116.