You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
6.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* Skeleton screen routines header.
  2. Copyright (c) 2002 by Salvador E. Tropea (SET)
  3. Covered by the GPL license. */
  4. /*
  5. This header is an example that could help somebody trying to write a new
  6. driver. The word "Skeleton" should be replaced by the target i.e. the OS.
  7. */
  8. // Here specify if this header requires some system specific header
  9. #ifndef SKELETONSCR_HEADER_INCLUDED
  10. #define SKELETONSCR_HEADER_INCLUDED
  11. // virtual to avoid problems with multiple inheritance
  12. class TDisplaySkeleton : virtual public TDisplay
  13. {
  14. protected:
  15. // Usually TDisplay contructor does nothing. All the magic is in TScreen
  16. // constructor, a class derived from it.
  17. TDisplaySkeleton() {};
  18. // We will use casts to base classes, destructors must be pointers.
  19. // Usually the magic goes in ~TScreenSkeleton
  20. virtual ~TDisplaySkeleton();
  21. // This sets the pointers of TDisplay to point to this class.
  22. static void Init();
  23. // Behaviors to replace TDisplay.
  24. // Note all of this is protected and is supposed to be used through TScreen
  25. // You can name these members as you like. Not all have to be implemented
  26. // and all have defaults.
  27. // Set text cursor position
  28. static void SetCursorPos(unsigned x, unsigned y);
  29. // Find text cursor position
  30. static void GetCursorPos(unsigned &x, unsigned &y);
  31. // What's the shape of the text cursor?
  32. static void GetCursorShape(unsigned &start, unsigned &end);
  33. // Set the shape of the text cursor
  34. static void SetCursorShape(unsigned start, unsigned end);
  35. // How many lines have the display?
  36. static ushort GetRows();
  37. // How many columns?
  38. static ushort GetCols();
  39. // Set a video mode number, usually not implemented, but sometimes you need to
  40. // set some defaults here.
  41. static void SetCrtMode(ushort mode);
  42. // Set a video mode using an external program
  43. static void SetCrtModeExt(char *mode);
  44. // Did the display changed its size since last call?
  45. static int CheckForWindowSize(void);
  46. // What's the title of our window?
  47. static const char *GetWindowTitle(void);
  48. // Set the title for our window
  49. static int SetWindowTitle(const char *name);
  50. // Produce an audible indication
  51. static void Beep();
  52. // Variables for this driver
  53. // Here you define variables needed by your driver.
  54. };
  55. // With this order the destructor will be called first for TScreenSkeleton,
  56. // TScreen, TDisplaySkeleton and finally TDisplay.
  57. class TScreenSkeleton : public TDisplaySkeleton, public TScreen
  58. {
  59. public:
  60. // Put the driver detection/initialization in this constructor
  61. TScreenSkeleton();
  62. // We will use casts to base classes, destructors must be pointers
  63. // Here you can put the code needed to restore the state of the machine
  64. // before initialization. Be very careful we the order and avoid doble
  65. // deinitializations.
  66. virtual ~TScreenSkeleton();
  67. // Usually our guts are needed by the key, mouse and/or display.
  68. // Here you can allow access to those classes.
  69. friend class TGKeySkeleton;
  70. friend class THWMouseSkeleton;
  71. friend class TDisplaySkeleton;
  72. protected:
  73. // Memorize the state of the console and set our state.
  74. static void Resume();
  75. // Restore the state the console had.
  76. static void Suspend();
  77. // This does a translation between video mode numbers passed to setVideoMode
  78. // and the values passed to setCrtMode.
  79. static ushort fixCrtMode(ushort mode);
  80. // This sets some internal variables with the current state of the console.
  81. // Take a look at the default in tscreen.cc
  82. static void setCrtData();
  83. // Clear the contents of the whole screen. Here just to be compatible with
  84. // original TV.
  85. static void clearScreen();
  86. // See TDisplaySkeleton::SetCrtMode, this is the function expossed to the
  87. // application.
  88. static void setVideoMode(ushort mode);
  89. // See TDisplaySkeleton::SetCrtModeExt, this is the function expossed to the
  90. // application.
  91. static void setVideoModeExt(char *mode);
  92. // The following four functions works with the screen buffer.
  93. // Internally TV uses ushort arrays to store the characters and their
  94. // attributes (8 bits each one). The organization is the same used by
  95. // PC VGA video cards. The format is independent of the endianess of
  96. // the architecture. If you cast the "short *" array to "unsigned char *"
  97. // the even positions will hold the characters and the odd positions the
  98. // attributes. The upper nibble of the attribute is the background and
  99. // the lower is the foreground color.
  100. // The driver should assign to screenBuffer the address of a buffer
  101. // containing the actual data displayed in the screen. In TV 1.x for DOS
  102. // it was a pointer to the video memory, in TV 2.0 it can be a pointer to
  103. // a buffer in memory or just any value, but can't remain NULL or
  104. // nothing will be sent to the screen.
  105. // When screenBuffer points to a buffer in memory setCharacter* should
  106. // output to the screen *and* hold a copy in this buffer. In this case
  107. // the default getCharacter* will do the job.
  108. // Get the char/attribute pairs at offset position (x=offset%cols,
  109. // y=offset/cols).
  110. static void getCharacters(unsigned offset,ushort *buf,unsigned count);
  111. static ushort getCharacter(unsigned dst);
  112. // Sets the char/attribute pairs.
  113. static void setCharacter(unsigned offset, ushort value);
  114. static void setCharacters(unsigned dst, ushort *src, unsigned len);
  115. // Calls an external program, if pidChild pointer is not null the routine
  116. // should try to do it in background and return the process ID.
  117. static int System(const char *command, pid_t *pidChild);
  118. // Sets the colors palette, currently upto 16 colors are supported
  119. static int SetDisPaletteColors(int from, int number, TScreenColor *colors);
  120. // Finds the width and height of the font currently used
  121. static int GetFontGeometry(unsigned &w, unsigned &h);
  122. // To know the smallest and biggest font sizes supported
  123. static int GetFontGeometryRange(unsigned &wmin, unsigned &hmin,
  124. unsigned &umax, unsigned &hmax);
  125. // It changes the screen fonts. Upto 2 fonts are supported and the driver
  126. // must use the capabilities (see Capabilities1 enum) to indicate if the
  127. // secondary font is supported.
  128. static int SetFont(int changeP, TScreenFont256 *fontP,
  129. int changeS, TScreenFont256 *fontS,
  130. int fontCP=-1, int appCP=-1);
  131. // Restore the original fonts
  132. static void RestoreFonts();
  133. // Sets a video mode indicating a size of the screen and font. The function
  134. // must look for the closest mode and indicate if we set what the user
  135. // requested or something different.
  136. static int SetCrtModeRes(unsigned w, unsigned h, int fW=-1, int fH=-1);
  137. // Show some sign to indicate we are temporally busy, it can be changing the
  138. // mouse cursor.
  139. static Boolean ShowBusyState(Boolean state);
  140. protected:
  141. // Put support routines and variables here
  142. };
  143. #endif // SKELETONSCR_HEADER_INCLUDED