home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gchsrc31 / include / fastcoun.h < prev    next >
C/C++ Source or Header  |  1992-04-27  |  2KB  |  80 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknoledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef _FastCounter_h
  13. #define _FastCounter_h
  14.  
  15. ///////////////////////////////////////////////////////////////////////////
  16. //
  17. //  Fast counters are high-speed decimal display objects.
  18. //  Currently, only implemented in STLow resolution.
  19. //
  20. //  To use, create a screen with "  0123456789" depicted in colour 15,
  21. //  each character 8 pixels wide, and all the same height.
  22. //
  23. //  Create a CounterFont from this screen.
  24. //
  25. //  Create a FastCounter from this font.
  26. //
  27. ///////////////////////////////////////////////////////////////////////////
  28.  
  29. #include <bool.h>
  30. #include <screen.h>
  31.  
  32. class CounterFont
  33. {
  34. public:
  35.     CounterFont(short Height, short Plane=0);
  36.  
  37.     // x must be multiple of 16
  38.     GetImages(Screen&,short x,short y);
  39.  
  40.     friend class FastCounter;
  41.     Draw(short,long Offset); // Draw "00" to "99"; 100+x=" x", 110="  "
  42.  
  43. private:
  44.     short *Data;
  45.     short shifts;
  46.     short height;
  47.     short plane;
  48. };
  49.  
  50. class FastCounter
  51. {
  52. public:
  53.     // Use given font, draw at (x,y) - x multiple of 16,
  54.     // initial counter value v, given number of digits (multiple of 2).
  55.     FastCounter(CounterFont*,int x,int y,unsigned v=0,short digits=6);
  56.     ~FastCounter();
  57.  
  58.     void Draw();            // Draw on current page
  59.     void Add(short);        // Increase/decrease
  60.     void Set(unsigned);
  61.     void operator ++ () {Add(1);}
  62.     void operator -- () {Add(-1);}
  63.     void operator += (short x) {Add(x);}
  64.     void operator -= (short x) {Add(-x);}
  65.     operator int();            // Convert to int
  66.     operator double();        // convert to double
  67.     void MoveTo(short x,short y);
  68.     void ZeroSuppression(bool on=TRUE);    // Turned on by default
  69.  
  70. private:
  71.     bool LeadingZeroes=FALSE;
  72.     CounterFont *Font;
  73.     unsigned short *Digit;
  74.     unsigned short Changed[2];
  75.     short Size;
  76.     long Offset;
  77. };
  78.  
  79. #endif
  80.