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.

185 lines
6.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**[txh]********************************************************************
  2. Copyright (c) 2001-2002 by Salvador E. Tropea
  3. Description:
  4. Display and Screen `driver' classes for DOS.
  5. ***************************************************************************/
  6. #if defined(TVCompf_djgpp) && !defined(DOS_SCREEN_HEADER_INCLUDED)
  7. #define DOS_SCREEN_HEADER_INCLUDED
  8. class THWMouseDOS;
  9. class TVDOSClipboard;
  10. // virtual to avoid problems with multiple inheritance
  11. class TDisplayDOS : virtual public TDisplay
  12. {
  13. protected:
  14. TDisplayDOS() {};
  15. // We will use casts to base classes, destructors must be pointers
  16. virtual ~TDisplayDOS();
  17. // This sets the pointers of TDisplay to point to this class
  18. static void Init();
  19. // Behaviors to replace TDisplay
  20. static void SetCursorPos(unsigned x, unsigned y);
  21. static void GetCursorPos(unsigned &x, unsigned &y);
  22. static void GetCursorShape(unsigned &start, unsigned &end);
  23. static void SetCursorShape(unsigned start, unsigned end);
  24. static void ClearScreen(uchar, uchar);
  25. static ushort GetRows();
  26. static ushort GetCols();
  27. static void SetCrtMode(ushort mode);
  28. static ushort GetCrtMode();
  29. static void SetCrtModeExt(char *mode);
  30. static int SetCrtModeRes(unsigned w, unsigned h, int fW, int fH);
  31. // Not available static int CheckForWindowSize(void);
  32. static
  33. const char *GetWindowTitle(void);
  34. static int SetWindowTitle(const char *name);
  35. static int SetDisPaletteColors(int from, int number, TScreenColor *colors);
  36. static void GetDisPaletteColors(int from, int number, TScreenColor *colors);
  37. static void Beep();
  38. // Function members for this driver
  39. // Calls the BIOS 0x10 interrupt (Video service)
  40. static void videoInt() { __dpmi_int(0x10,&rDisplay); };
  41. // Finds the number of lines per char
  42. static int getCharLines();
  43. // Special videoInt to workaround a bug in NT's TXProII driver
  44. static void setVideoModeInt();
  45. // Selects a text mode, it detects if the mode is VESA
  46. static void setTextMode();
  47. // Select the number of scanlines and font to use.
  48. // Used to set extended video modes, like 80x50.
  49. static void setExtendedMode(int mode);
  50. // Is used to test if a mode that we don't know can be handled by the driver
  51. // or not. If the mode uses an unknown memory region we just assume that's
  52. // a graphics mode and revert to 80x25. It could be enhanced.
  53. static void testForSupport();
  54. // Selects a VESA or user provided video mode.
  55. static void setTextMode(int mode);
  56. // Sets a tweaked video mode
  57. static int setTweakedMode(int mode);
  58. // Reads the palette map
  59. static void getPaletteMap(char *map);
  60. // Low level BIOS calls to get/set one palette index
  61. static void setOnePaletteIndex(int index, TScreenColor *col);
  62. static void getOnePaletteIndex(int index, TScreenColor *col);
  63. static int dosInt() { return __dpmi_int(0x21,&rDisplay); };
  64. // Data members for this driver
  65. static __dpmi_regs rDisplay;
  66. static unsigned charLines;
  67. static char emulateMouse;
  68. // The 16 available colors are a subset of the 256 colors the VGA controller
  69. // handles. Additionally the border color is defined in this map.
  70. // The following map indicates which palette index is associated with
  71. // each palette index.
  72. static char colorsMap[17];
  73. friend class TVDOSClipboard;
  74. };
  75. // With this order the destructor will be called first for TScreenDOS,
  76. // TScreen, TDisplayDOS and finally TDisplay.
  77. class TScreenDOS : public TDisplayDOS, public TScreen
  78. {
  79. public:
  80. TScreenDOS();
  81. // We will use casts to base classes, destructors must be pointers
  82. virtual ~TScreenDOS();
  83. // Is that really used?
  84. static int slowScreen;
  85. friend class TDisplayDOS; // *=-P
  86. protected:
  87. static void Resume();
  88. static void Suspend();
  89. static void setCrtData();
  90. static void clearScreen();
  91. static void getCharacters(unsigned offset,ushort *buf,unsigned count);
  92. static ushort getCharacter(unsigned dst);
  93. static void setCharacter(unsigned offset,uint32 value);
  94. static void setCharacters(unsigned dst,ushort *src,unsigned len);
  95. static int System(const char *command, pid_t *pidChild, int in, int out,
  96. int err);
  97. static int GetFontGeometry(unsigned &w, unsigned &h);
  98. static int SetFont(int changeP, TScreenFont256 *fontP,
  99. int changeS, TScreenFont256 *fontS,
  100. int fontCP=-1, int appCP=-1);
  101. static void RestoreFonts();
  102. // Fonts stuff
  103. static void SetDualCharacter(int b1, int b2);
  104. static void EnableDualFont() { SetDualCharacter(0,1); };
  105. static void DisableDualFont() { SetDualCharacter(0,0); };
  106. static void SetFontBIOS(int which, unsigned height, uchar *data, int modeRecalculate);
  107. static int Load8x10Font(int which, int modeRecalculate);
  108. static void MaybeCreate8x10Font(void);
  109. static void SetRomFonts(int sizeFont, int which, int modeRecalculate);
  110. static int SelectRomFont(int height, int which, int modeRecalculate);
  111. static void ReleaseMemFonts();
  112. static int MemorizeFont(int which, TScreenFont256 *font);
  113. static void SuspendFonts();
  114. static void ResumeFonts();
  115. static void SelectFont(unsigned height, Boolean Force=False);
  116. static uchar primaryFontSet,secondaryFontSet;
  117. static uchar fontsSuspended;
  118. static int origCPScr, origCPApp, origCPInp;
  119. static int fontSeg; // segment of DOS buffer for 8x10 font
  120. static TScreenFont256 appFonts[2];
  121. // Status before suspending
  122. static int wasBlink;
  123. };
  124. class TVDOSClipboard
  125. {
  126. public:
  127. TVDOSClipboard() {};
  128. protected:
  129. // Replacements for the TVOSClipboard class
  130. static int copy(int id, const char *buffer, unsigned len);
  131. static char *paste(int id, unsigned &length);
  132. // Members for this class
  133. static int Init();
  134. static int AllocateDOSMem(unsigned long size, unsigned long *BaseAddress);
  135. static void FreeDOSMem(unsigned long Address);
  136. static int MultiplexInt() { return __dpmi_int(0x2F,&TDisplayDOS::rDisplay); };
  137. static const
  138. char *dosNameError[];
  139. static int isValid;
  140. static int Version;
  141. friend class TScreenDOS;
  142. };
  143. #ifdef TSCREEN_DEFINE_REGISTERS
  144. #define r (TDisplayDOS::rDisplay)
  145. #define AL (r.h.al)
  146. #define BL (r.h.bl)
  147. #define CL (r.h.cl)
  148. #define DL (r.h.dl)
  149. #define AH (r.h.ah)
  150. #define BH (r.h.bh)
  151. #define CH (r.h.ch)
  152. #define DH (r.h.dh)
  153. #define AX (r.x.ax)
  154. #define BX (r.x.bx)
  155. #define CX (r.x.cx)
  156. #define DX (r.x.dx)
  157. #define DI (r.x.di)
  158. #define SI (r.x.si)
  159. #define BP (r.x.bp)
  160. #define ES (r.x.es)
  161. #endif // TSCREEN_DEFINE_REGISTERS
  162. #endif // DOS_SCREEN_HEADER_INCLUDED