home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / OUTLINE.ACC / STATUS.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  4.6 KB  |  190 lines

  1. /* FILE: STATUS.C
  2.  * ======================================================================
  3.  * DATE:  January 29, 1991
  4.  *        May      6, 1992
  5.  *      October 27, 1992
  6.  *
  7.  * DESCRIPTION: Calculate the usage of FSM data cache.
  8.  *
  9.  * INCLUDE FILE: STATUS.H
  10.  *
  11.  * FSM DATA CACHE USAGE:
  12.  *
  13.  *    FSM----------------------
  14.  *
  15.  *      NAME        AMOUNT (bytes)         USAGE
  16.  *      -----------------------------------------------------
  17.  *      fsmheader    80            1 per font
  18.  *    fontp_actual    180            1 per workstation
  19.  *    width_table    458            1 per font per pointsize.
  20.  *                        ( if width_tables are on)
  21.  *    ptsblk         6            1 per font per pointsize.
  22.  *    arb/ptsblk    28            1 to 8 members per font
  23.  *
  24.  *      ------------------------------------------------------
  25.  *
  26.  *  The TOTAL available FSM data cache area is:
  27.  *
  28.  *  extern XFSM Current.SpeedoCacheSize;
  29.  *  extern XFSM Current.speedo_percent;
  30.  *
  31.  *  Size of Misc Data Cache =
  32.  *  ( Current.SpeedoCacheSize * ( 100 - ( Current.speedo_percent * 10 )) )/100;
  33.  *
  34.  */
  35.  
  36.  
  37. /* INCLUDE FILES
  38.  * ======================================================================
  39.  */
  40. #include <sys\gemskel.h>
  41.  
  42. #include "country.h"
  43. #include "fonthead.h"
  44. #include "fsmio.h"
  45. #include "fonts.h"
  46. #include "mainstuf.h"
  47. #include "text.h"
  48. #include "cache.h"
  49. #include "front.h"
  50.  
  51.  
  52.  
  53. /* PROTOTYPES
  54.  * ======================================================================
  55.  */
  56. void    CacheCheck( void );
  57. long    GetCurUsage( void );
  58. void    CachePrompt( void );
  59.  
  60.  
  61.  
  62. /* DEFINES
  63.  * ======================================================================
  64.  */
  65. /* FSM FONTS */
  66. #define    FSMHEADER     80L
  67. #define FONTP_ACTUAL     180L
  68. #define WIDTH_TABLE_DATA 458L
  69. #define    THE_PTSBLK      6L
  70. #define    ARB_PTSBLK     28L
  71.  
  72.  
  73. /* EXTERN
  74.  * ======================================================================
  75.  */
  76.  
  77.  
  78. /* GLOBALS
  79.  * ======================================================================
  80.  */
  81. long    CacheDataSize;        /* FSM Data Cache Size */
  82. long    CacheUsedSize;        /* FSM Data Cache Size calculated used*/
  83.  
  84.  
  85. /* FUNCTIONS
  86.  * ======================================================================
  87.  */
  88.  
  89.  
  90. /* GetCurUsage()
  91.  * ======================================================================
  92.  * Get the current Speedo Data Cache Usage.
  93.  */
  94. long
  95. GetCurUsage( void )
  96. {
  97.     FON_PTR  curptr;
  98.     int      i;
  99.     long     Used;
  100.     int      icount;
  101.  
  102.     /* Get the Fixed amount - always have this...*/
  103.     Used = FONTP_ACTUAL;
  104.     
  105.     /* Get the per font allocation */
  106.     icount = CountFonts( installed_list, SPD_FONT );
  107.     
  108.     Used +=  (long)icount * ( FSMHEADER + ARB_PTSBLK );
  109.     
  110.     /* Get the per pointsize per font allocation. */
  111.     curptr = installed_list;
  112.     while( curptr )
  113.     {
  114.        if( FTYPE( curptr ) == SPD_FONT )
  115.        {
  116.          for( i=0; i < MAX_POINTS; i++ )
  117.          {
  118.            if( POINTS( curptr )[i] )
  119.            {
  120.               if( Current.Width )
  121.                  Used += WIDTH_TABLE_DATA;
  122.               Used += THE_PTSBLK;
  123.            }
  124.            else
  125.             break;
  126.          }
  127.        }         
  128.        curptr = FNEXT( curptr );
  129.     }
  130.     
  131.     Used += ( GetFontMin() + GetCharMin() );
  132.     
  133.     /* Make sure we ALWAYS have at least 10K */
  134.     if( Used < 10240L )
  135.       Used = 10240L;    
  136.  
  137.     Used /= 1024L;
  138.     return( Used );
  139. }
  140.  
  141.  
  142.  
  143. /* CacheCheck()
  144.  * ======================================================================
  145.  * Checks the CacheUsedSize vs the CacheDataSize.
  146.  * Note: This is a check against the CPX setting. NOT the
  147.  * actual setting. This checks the Miscellaneous size against
  148.  * the used amount.
  149.  */
  150. void
  151. CacheCheck( void )
  152. {
  153.    long extra;
  154.    long interim;
  155.  
  156.    interim = (100L - ( (long)Current.speedo_percent * 10L )) * Current.SpeedoCacheSize;
  157.    extra = ( interim % 100L ) > 50L;
  158.    CacheDataSize = ( interim / 100L ) + extra;
  159.  
  160.    
  161.    CacheUsedSize = GetCurUsage();
  162.  
  163.    if( ( CacheUsedSize ) > CacheDataSize )
  164.       form_alert( 1, alert21 );   /* Put out a warning...*/
  165. }
  166.  
  167.  
  168. /* CachePrompt()
  169.  * ======================================================================
  170.  * Used only by the write_extend.sys routine. This is so that if
  171.  * we have used more cache than we should've, we'll warn them.
  172.  * return: TRUE - Don't write the extend.sys
  173.  *       FALSE- Write the extend.sys
  174.  */
  175. void
  176. CachePrompt( void )
  177. {
  178.    long extra;
  179.    long interim;
  180.  
  181.    interim = (100L - ( (long)Current.speedo_percent * 10L )) * Current.SpeedoCacheSize;
  182.    extra = ( interim % 100L ) > 50L;
  183.    CacheDataSize = ( interim / 100L ) + extra;
  184.    
  185.    CacheUsedSize = GetCurUsage();
  186.  
  187.    if( ( CacheUsedSize ) > CacheDataSize )
  188.       form_alert( 1, alert22 );   /* Put out a warning...*/
  189. }
  190.