monodrvr.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /G/wwlib/monodrvr.h $*
  25. * *
  26. * $Author:: Neal_k $*
  27. * *
  28. * $Modtime:: 10/04/99 10:25a $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if _MSC_VER >= 1000
  36. #pragma once
  37. #endif // _MSC_VER >= 1000
  38. #ifdef _MSC_VER
  39. #pragma warning (push,3)
  40. #endif
  41. #ifdef _WINDOWS
  42. #include <winioctl.h>
  43. #endif
  44. #ifdef _MSC_VER
  45. #pragma warning (pop)
  46. #endif
  47. /*
  48. ** This is the identifier for the Monochrome Display Driver.
  49. */
  50. #define FILE_DEVICE_MONO 0x00008000
  51. /*
  52. ** These are the IOCTL commands supported by the Monochrome Display Driver.
  53. */
  54. #define IOCTL_MONO_HELP_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x800, METHOD_BUFFERED, FILE_WRITE_DATA)
  55. #define IOCTL_MONO_CLEAR_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x801, METHOD_BUFFERED, FILE_WRITE_DATA)
  56. #define IOCTL_MONO_PRINT_RAW CTL_CODE(FILE_DEVICE_MONO, 0x802, METHOD_BUFFERED, FILE_WRITE_DATA)
  57. #define IOCTL_MONO_SET_CURSOR CTL_CODE(FILE_DEVICE_MONO, 0x803, METHOD_BUFFERED, FILE_WRITE_DATA)
  58. #define IOCTL_MONO_SCROLL CTL_CODE(FILE_DEVICE_MONO, 0x804, METHOD_BUFFERED, FILE_WRITE_DATA)
  59. #define IOCTL_MONO_BRING_TO_TOP CTL_CODE(FILE_DEVICE_MONO, 0x805, METHOD_BUFFERED, FILE_WRITE_DATA)
  60. #define IOCTL_MONO_SET_ATTRIBUTE CTL_CODE(FILE_DEVICE_MONO, 0x806, METHOD_BUFFERED, FILE_WRITE_DATA)
  61. #define IOCTL_MONO_PAN CTL_CODE(FILE_DEVICE_MONO, 0x807, METHOD_BUFFERED, FILE_WRITE_DATA)
  62. #define IOCTL_MONO_LOCK CTL_CODE(FILE_DEVICE_MONO, 0x808, METHOD_BUFFERED, FILE_WRITE_DATA)
  63. #define IOCTL_MONO_UNLOCK CTL_CODE(FILE_DEVICE_MONO, 0x809, METHOD_BUFFERED, FILE_WRITE_DATA)
  64. #define IOCTL_MONO_SET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80A, METHOD_BUFFERED, FILE_WRITE_DATA)
  65. #define IOCTL_MONO_RESET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80B, METHOD_BUFFERED, FILE_WRITE_DATA)
  66. #define IOCTL_MONO_SET_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80C, METHOD_BUFFERED, FILE_WRITE_DATA)
  67. #define IOCTL_MONO_CLEAR_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80D, METHOD_BUFFERED, FILE_WRITE_DATA)
  68. #define IOCTL_MONO_FILL_ATTRIB CTL_CODE(FILE_DEVICE_MONO, 0x80E, METHOD_BUFFERED, FILE_WRITE_DATA)
  69. /*
  70. ** These specify the various behavior flags available for the mono display driver. They
  71. ** default to being OFF (or FALSE).
  72. */
  73. typedef enum MonoFlagType
  74. {
  75. MONOFLAG_WRAP, // Text will wrap to the next line when right margin is reached.
  76. MONOFLAG_COUNT // Used to indicate the number of mono flags available.
  77. } MonoFlagType;
  78. /*
  79. Here is a "C" example of how to use the Monochrome Display Driver.
  80. int main(int argc, char *argv[])
  81. {
  82. HANDLE handle;
  83. handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  84. if (handle != INVALID_HANDLE_VALUE) {
  85. long retval; // Return code from IoControl functions.
  86. unsigned short * pointer; // Working pointer to mono RAM.
  87. union {
  88. int X,Y;
  89. } cursor; // Cursor positioning parameter info.
  90. // Prints a line of text to the screen [length of string is 13].
  91. WriteFile(handle, "Test Message\n", 13, &retval, NULL);
  92. // Fetches a pointer to the mono memory.
  93. DeviceIoControl(handle, (DWORD)IOCTL_MONO_LOCK, NULL, 0, &pointer, sizeof(pointer), &retval, 0);
  94. if (pointer != NULL) {
  95. *pointer = 0x0721; // '!' character appears in upper left corner (attribute 0x07).
  96. }
  97. DeviceIoControl(handle, (DWORD)IOCTL_MONO_UNLOCK, NULL, 0, NULL, 0, &retval, 0);
  98. // Set cursor to column 5, row 10.
  99. cursor.X = 5;
  100. cursor.Y = 10;
  101. DeviceIoControl(handle, (DWORD)IOCTL_MONO_SET_CURSOR, &cursor, sizeof(cursor), NULL, 0, &retval, 0);
  102. // Clear the screen.
  103. DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &retval, 0);
  104. CloseHandle(handle);
  105. }
  106. return 0;
  107. }
  108. */