MONO.CPP 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. /*
  2. ** Command & Conquer Red Alert(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. /* $Header: F:\projects\c&c\vcs\code\monoc.cpv 2.12 06 Sep 1995 16:37:54 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : MONO.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : July 2, 1994 *
  30. * *
  31. * Last Update : October 17, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * MonoClass::Clear -- Clears the monochrome screen object. *
  36. * MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. *
  37. * MonoClass::MonoClass -- The default constructor for monochrome screen object. *
  38. * MonoClass::operator = -- Handles making one mono object have the same imagery as another. *
  39. * MonoClass::Print -- Prints the text string at the current cursor coordinates. *
  40. * MonoClass::Printf -- Prints a formatted string to the monochrome screen. *
  41. * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. *
  42. * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. *
  43. * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. *
  44. * MonoClass::View -- Brings the mono object to the main display. *
  45. * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. *
  46. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  47. //#pragma inline
  48. #include "mono.h"
  49. #include <stdlib.h>
  50. #include <stdio.h>
  51. #include <dos.h>
  52. #include <mem.h>
  53. #include <stdarg.h>
  54. #include <string.h>
  55. extern void output(short port, short data);
  56. #pragma aux output parm [dx] [ax] = \
  57. "out dx,al" \
  58. "inc dx" \
  59. "mov al,ah" \
  60. "out dx,al"
  61. int MonoClass::Enabled = 0;
  62. MonoClass * MonoClass::PageUsage[MonoClass::MAX_MONO_PAGES] = {0,0,0,0,0,0,0,0};
  63. void * MonoClass::MonoSegment = (void*)0x000b0000;
  64. /*
  65. ** These are the IBM linedraw characters.
  66. */
  67. MonoClass::BoxDataType const MonoClass::CharData[MonoClass::COUNT] = {
  68. {0xDA,0xC4,0xBF,0xB3,0xD9,0xC4,0xC0,0xB3}, // Single line
  69. {0xD5,0xCD,0xB8,0xB3,0xBE,0xCD,0xD4,0xB3}, // Double horz.
  70. {0xD6,0xC4,0xB7,0xBA,0xBD,0xC4,0xD3,0xBA}, // Double vert.
  71. {0xC9,0xCD,0xBB,0xBA,0xBC,0xCD,0xC8,0xBA} // Double horz and vert.
  72. };
  73. /***********************************************************************************************
  74. * MonoClass::MonoClass -- The default constructor for monochrome screen object. *
  75. * *
  76. * This is the constructor for monochrome screen objects. It handles allocating a free *
  77. * monochrome page. If there are no more pages available, then this is a big error. The *
  78. * page allocated may not be the visible one. Call the View function in order to bring *
  79. * it to the displayed page. *
  80. * *
  81. * INPUT: none *
  82. * *
  83. * OUTPUT: none *
  84. * *
  85. * WARNINGS: none *
  86. * *
  87. * HISTORY: *
  88. * 10/17/1994 JLB : Created. *
  89. *=============================================================================================*/
  90. MonoClass::MonoClass(void)
  91. {
  92. int index;
  93. Attrib = DEFAULT_ATTRIBUTE; // Normal text color.
  94. X = Y = 0;
  95. for (index = 0; index < MAX_MONO_PAGES; index++) {
  96. if (!PageUsage[index]) {
  97. PageUsage[index] = this;
  98. Page = (char)index;
  99. break;
  100. }
  101. }
  102. if (index == MAX_MONO_PAGES) {
  103. // Major error message should pop up here!
  104. delete this;
  105. }
  106. }
  107. /***********************************************************************************************
  108. * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. *
  109. * *
  110. * This is the default destructor for a monochrome screen object. *
  111. * *
  112. * INPUT: none *
  113. * *
  114. * OUTPUT: none *
  115. * *
  116. * WARNINGS: none *
  117. * *
  118. * HISTORY: *
  119. * 10/17/1994 JLB : Created. *
  120. *=============================================================================================*/
  121. MonoClass::~MonoClass(void)
  122. {
  123. PageUsage[Page] = 0;
  124. }
  125. /***********************************************************************************************
  126. * MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. *
  127. * *
  128. * Use this routine to draw a box to the monochrome screen. The IBM line draw characters *
  129. * are used to give the it a fancy appearance. There are several line draw modes supported. *
  130. * *
  131. * INPUT: x,y -- The coordinates of the upper left corner of the box. *
  132. * *
  133. * w,y -- The width and height (respectively) to make the box. *
  134. * *
  135. * attrib -- The text attribute to use when drawing the box outline characters. *
  136. * *
  137. * thick -- The thickness style to use. Examine the BoxStyleType enum for *
  138. * elaboration on the supported styles. *
  139. * *
  140. * OUTPUT: none *
  141. * *
  142. * WARNINGS: The interior of the box is NOT cleared by this routine. It is advised that this *
  143. * area be cleared before the box is drawn. *
  144. * *
  145. * HISTORY: *
  146. * 10/17/1994 JLB : Created. *
  147. *=============================================================================================*/
  148. void MonoClass::Draw_Box(int x, int y, int w, int h, char attrib, BoxStyleType thick)
  149. {
  150. CellType cell;
  151. char oldattrib = Attrib;
  152. if (!Enabled || !w || !h) return;
  153. cell.Attribute = attrib;
  154. /*
  155. ** Draw the horizontal lines.
  156. */
  157. for (int xpos = 0; xpos < w-2; xpos++) {
  158. cell.Character = CharData[thick].TopEdge;
  159. Store_Cell(cell, x+xpos+1, y);
  160. cell.Character = CharData[thick].BottomEdge;
  161. Store_Cell(cell, x+xpos+1, y+h-1);
  162. }
  163. /*
  164. ** Draw the vertical lines.
  165. */
  166. for (int ypos = 0; ypos < h-2; ypos++) {
  167. cell.Character = CharData[thick].LeftEdge;
  168. Store_Cell(cell, x, y+ypos+1);
  169. cell.Character = CharData[thick].RightEdge;
  170. Store_Cell(cell, x+w-1, y+ypos+1);
  171. }
  172. /*
  173. ** Draw the four corners.
  174. */
  175. if (w > 1 && h > 1) {
  176. cell.Character = CharData[thick].UpperLeft;
  177. Store_Cell(cell, x, y);
  178. cell.Character = CharData[thick].UpperRight;
  179. Store_Cell(cell, x+w-1, y);
  180. cell.Character = CharData[thick].BottomRight;
  181. Store_Cell(cell, x+w-1, y+h-1);
  182. cell.Character = CharData[thick].BottomLeft;
  183. Store_Cell(cell, x, y+h-1);
  184. }
  185. Attrib = oldattrib;
  186. }
  187. /***********************************************************************************************
  188. * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. *
  189. * *
  190. * Use this routine to set the monochrome's cursor position to the coordinates specified. *
  191. * This is the normal way of controlling where the next Print or Printf will output the *
  192. * text to. *
  193. * *
  194. * INPUT: x,y -- The coordinate to position the monochrome cursor. 0,0 is the upper left *
  195. * corner. *
  196. * *
  197. * OUTPUT: none *
  198. * *
  199. * WARNINGS: none *
  200. * *
  201. * HISTORY: *
  202. * 10/17/1994 JLB : Created. *
  203. *=============================================================================================*/
  204. void MonoClass::Set_Cursor(int x, int y)
  205. {
  206. #if(0)
  207. int pos = (y*COLUMNS)+x;
  208. if (!Enabled) return;
  209. X = (char)(x%COLUMNS);
  210. Y = (char)(y%LINES);
  211. if (Page == 0) {
  212. _DX = CONTROL_PORT;
  213. _AX = (short)(0x0E|(pos&0xFF00));
  214. asm {
  215. out dx,al
  216. inc dx
  217. mov al,ah
  218. out dx,al
  219. }
  220. _DX = CONTROL_PORT;
  221. _AX = (short)(0x0F|(pos<<8));
  222. asm {
  223. out dx,al
  224. inc dx
  225. mov al,ah
  226. out dx,al
  227. }
  228. }
  229. #else
  230. int pos = (y*COLUMNS)+x;
  231. if (!Enabled) return;
  232. X = (char)(x%COLUMNS);
  233. Y = (char)(y%LINES);
  234. if (Page == 0) {
  235. output(CONTROL_PORT,
  236. (short)0x0E|(short)(pos&0xFF00));
  237. output(CONTROL_PORT,
  238. (short)0x0F|(short)(pos<<8));
  239. }
  240. #endif
  241. }
  242. /***********************************************************************************************
  243. * MonoClass::Clear -- Clears the monochrome screen object. *
  244. * *
  245. * This routine will fill the monochrome screen object with spaces. It is clearing the *
  246. * screen of data, making it free for output. The cursor is positioned at the upper left *
  247. * corner of the screen by this routine. *
  248. * *
  249. * INPUT: none *
  250. * *
  251. * OUTPUT: none *
  252. * *
  253. * WARNINGS: none *
  254. * *
  255. * HISTORY: *
  256. * 10/17/1994 JLB : Created. *
  257. *=============================================================================================*/
  258. void MonoClass::Clear(void)
  259. {
  260. CellType cell;
  261. if (!Enabled) return;
  262. Set_Cursor(0, 0);
  263. cell.Attribute = Attrib;
  264. cell.Character = ' ';
  265. for (int y = 0; y < LINES; y++) {
  266. for (int x = 0; x < COLUMNS; x++) {
  267. Store_Cell(cell, x, y);
  268. }
  269. }
  270. }
  271. /***********************************************************************************************
  272. * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. *
  273. * *
  274. * Use this routine to scroll the monochrome screen up by the number of lines specified. *
  275. * This routine is typically called by the printing functions so that the monochrome screen *
  276. * behaves in the expected manner -- printing at the bottom of the screen scrolls it up *
  277. * to make room for new text. *
  278. * *
  279. * INPUT: lines -- The number of lines to scroll the monochrome screen. *
  280. * *
  281. * OUTPUT: none *
  282. * *
  283. * WARNINGS: none *
  284. * *
  285. * HISTORY: *
  286. * 10/17/1994 JLB : Created. *
  287. *=============================================================================================*/
  288. void MonoClass::Scroll(int lines)
  289. {
  290. CellType cell;
  291. if (!Enabled || lines <= 0) return;
  292. memmove( (void*)((long)MonoSegment + Offset(0, 0)),
  293. (void*)((long)MonoSegment + Offset(0, lines)),
  294. (LINES-lines)*COLUMNS*sizeof(CellType));
  295. Y--;
  296. cell.Attribute = Attrib;
  297. cell.Character = ' ';
  298. for (int l = LINES-lines; l < LINES; l++) {
  299. for (int index = 0; index < COLUMNS; index++) {
  300. Store_Cell(cell, index, l);
  301. }
  302. }
  303. }
  304. /***********************************************************************************************
  305. * MonoClass::Printf -- Prints a formatted string to the monochrome screen. *
  306. * *
  307. * Use this routine to output a formatted string, using the standard formatting options, *
  308. * to the monochrome screen object's current cursor position. *
  309. * *
  310. * INPUT: text -- Pointer to the text to print. *
  311. * *
  312. * ... -- Any optional parameters to supply in formatting the text. *
  313. * *
  314. * OUTPUT: none *
  315. * *
  316. * WARNINGS: The total formatted text length must not exceed 255 characters. *
  317. * *
  318. * HISTORY: *
  319. * 10/17/1994 JLB : Created. *
  320. *=============================================================================================*/
  321. void MonoClass::Printf(char const *text, ...)
  322. {
  323. va_list va;
  324. /*
  325. ** The buffer object is placed at the end of the local variable list
  326. ** so that if the sprintf happens to spill past the end, it isn't likely
  327. ** to trash anything (important). The buffer is then manually truncated
  328. ** to maximum allowed size before being printed.
  329. */
  330. char buffer[256];
  331. if (!Enabled) return;
  332. va_start(va, text);
  333. vsprintf(buffer, text, va);
  334. buffer[sizeof(buffer)-1] = '\0';
  335. Print(buffer);
  336. va_end(va);
  337. }
  338. #ifdef NEVER
  339. void MonoClass::Printf(int text, ...)
  340. {
  341. va_list va;
  342. /*
  343. ** The buffer object is placed at the end of the local variable list
  344. ** so that if the sprintf happens to spill past the end, it isn't likely
  345. ** to trash anything (important). The buffer is then manually truncated
  346. ** to maximum allowed size before being printed.
  347. */
  348. char buffer[256];
  349. if (!Enabled) return;
  350. va_start(va, text);
  351. vsprintf(buffer, Text_String(text), va);
  352. buffer[sizeof(buffer)-1] = '\0';
  353. Print(buffer);
  354. va_end(va);
  355. }
  356. #endif
  357. /***********************************************************************************************
  358. * MonoClass::Print -- Prints the text string at the current cursor coordinates. *
  359. * *
  360. * Use this routine to output the specified text string at the monochrome object's current *
  361. * text coordinate position. *
  362. * *
  363. * INPUT: ptr -- Pointer to the string to print. *
  364. * *
  365. * OUTPUT: none *
  366. * *
  367. * WARNINGS: none *
  368. * *
  369. * HISTORY: *
  370. * 10/17/1994 JLB : Created. *
  371. *=============================================================================================*/
  372. void MonoClass::Print(char const *ptr)
  373. {
  374. char startcol = X;
  375. char const * text;
  376. CellType cell;
  377. if (!ptr || !Enabled) return;
  378. text = ptr;
  379. cell.Attribute = Attrib;
  380. while (*text) {
  381. /*
  382. ** Sometimes the character string is used for cursor control instead
  383. ** of plain text output. Check for this case.
  384. */
  385. switch (*text) {
  386. /*
  387. ** The "return" code behaves as it did in the old C library
  388. ** mono system. That is, it returns the cursor position to
  389. ** the next line but at the starting column of the print.
  390. */
  391. case '\r':
  392. X = startcol;
  393. Y++;
  394. Scroll(Y-(LINES-1));
  395. break;
  396. /*
  397. ** The "newline" code behaves like the console newline character.
  398. ** That is, it moves the cursor down one line and at the first
  399. ** column.
  400. */
  401. case '\n':
  402. X = 0;
  403. Y++;
  404. Scroll(Y-(LINES-1));
  405. break;
  406. /*
  407. ** All other characters are output directly and the cursor moves
  408. ** rightward to match. If the cursor wraps past the right
  409. ** edge is it moved to the next now down at left margin. If the
  410. ** cursor goes off the bottom of the display, the display is scrolled
  411. ** upward a line.
  412. */
  413. default:
  414. cell.Character = *text;
  415. Store_Cell(cell, X, Y);
  416. X++;
  417. if (X >= COLUMNS) {
  418. X = 0;
  419. Y++;
  420. if (Y > (LINES-1)) {
  421. Scroll(Y-(LINES-1));
  422. }
  423. }
  424. break;
  425. }
  426. text++;
  427. }
  428. Set_Cursor(X, Y);
  429. }
  430. /***********************************************************************************************
  431. * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. *
  432. * *
  433. * Use this routine to output text to the monochrome object at the X and Y coordinates *
  434. * specified. *
  435. * *
  436. * INPUT: text -- Pointer to the text string to display. *
  437. * *
  438. * x,y -- The X and Y character coordinates to start the printing at. *
  439. * *
  440. * attrib-- Optional parameter that specifies what text attribute code to use. *
  441. * *
  442. * OUTPUT: none *
  443. * *
  444. * WARNINGS: none *
  445. * *
  446. * HISTORY: *
  447. * 10/17/1994 JLB : Created. *
  448. *=============================================================================================*/
  449. void MonoClass::Text_Print(char const *text, int x, int y, char attrib)
  450. {
  451. char oldx = X;
  452. char oldy = Y;
  453. char oldattrib = Attrib;
  454. X = (char)x;
  455. Y = (char)y;
  456. Attrib = attrib;
  457. Print(text);
  458. Attrib = oldattrib;
  459. Set_Cursor(oldx, oldy);
  460. }
  461. #ifdef NEVER
  462. void MonoClass::Text_Print(int text, int x, int y, char attrib)
  463. {
  464. char oldx = X;
  465. char oldy = Y;
  466. char oldattrib = Attrib;
  467. if (text != TXT_NONE) {
  468. X = (char)x;
  469. Y = (char)y;
  470. Attrib = attrib;
  471. Print(Text_String(text));
  472. Attrib = oldattrib;
  473. Set_Cursor(oldx, oldy);
  474. }
  475. }
  476. void MonoClass::Print(int text)
  477. {
  478. Print(Text_String(text));
  479. }
  480. #endif
  481. /***********************************************************************************************
  482. * MonoClass::operator = -- Handles making one mono object have the same imagery as another. *
  483. * *
  484. * The assignment operator will handle copying the imagery from one monochrome object to *
  485. * another. Use this routine in to make two monochrome class objects visually identical. *
  486. * *
  487. * INPUT: src -- A reference to the source (right side) monochrome object. *
  488. * *
  489. * OUTPUT: none *
  490. * *
  491. * WARNINGS: none *
  492. * *
  493. * HISTORY: *
  494. * 10/17/1994 JLB : Created. *
  495. *=============================================================================================*/
  496. MonoClass & MonoClass::operator = (MonoClass const & src)
  497. {
  498. memcpy((void*)((long)MonoSegment + src.Offset(0, 0)), (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
  499. Set_Cursor(src.X, src.Y);
  500. return(*this);
  501. }
  502. /***********************************************************************************************
  503. * MonoClass::View -- Brings the mono object to the main display. *
  504. * *
  505. * Use this routine to display the mono object on the monochrome screen. It is possible *
  506. * that the mono object exists on some background screen memory. Calling this routine will *
  507. * perform the necessary memory swapping to bring the data to the front. The mono object *
  508. * that was currently being viewed is not destroyed by this function. It is merely moved *
  509. * off to some background page. It can be treated normally, except that is just isn't *
  510. * visible. *
  511. * *
  512. * INPUT: none *
  513. * *
  514. * OUTPUT: none *
  515. * *
  516. * WARNINGS: none *
  517. * *
  518. * HISTORY: *
  519. * 10/17/1994 JLB : Created. *
  520. *=============================================================================================*/
  521. void MonoClass::View(void)
  522. {
  523. MonoClass *displace; // The page that is being displaced.
  524. if (Get_Current() == this) return;
  525. /*
  526. ** If the visible page is already assigned to a real monochrome page
  527. ** object, then it must be swapped with the new one.
  528. */
  529. displace = Get_Current();
  530. if (displace) {
  531. char temp[SIZE_OF_PAGE];
  532. memcpy(&temp[0], MonoSegment, SIZE_OF_PAGE);
  533. memcpy(MonoSegment, (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
  534. memcpy((void*)((long)MonoSegment + Offset(0, 0)), &temp[0], SIZE_OF_PAGE);
  535. displace->Page = Page;
  536. } else {
  537. /*
  538. ** Just copy the new page over since the display page is not assigned
  539. ** to a real monochrome page object.
  540. */
  541. memcpy(MonoSegment, (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
  542. }
  543. PageUsage[Page] = displace;
  544. PageUsage[0] = this;
  545. Page = 0;
  546. Set_Cursor(X, Y);
  547. }
  548. /************************************************************************************
  549. ** This is the set of C wrapper functions that access the MonoClass support routines.
  550. ** Since the C interface doesn't have the ability to write to non-visible pages, it
  551. ** will just blast the output to whichever mono page is currently visible. If there is
  552. ** no mono class object that is visible, then one will be created -- BUT NOT FREED.
  553. ** Typically, this is ok, since the C interface will create only one MonoClass object
  554. ** and the system supports up to 8.
  555. */
  556. void Mono_Set_Cursor(int x, int y)
  557. {
  558. if (MonoClass::Is_Enabled()) {
  559. MonoClass *mono = MonoClass::Get_Current();
  560. if (!mono) {
  561. mono = new MonoClass();
  562. mono->View();
  563. }
  564. mono->Set_Cursor(x, y);
  565. }
  566. }
  567. int Mono_Printf(char const *string, ...)
  568. {
  569. va_list va;
  570. char buffer[256];
  571. buffer[0] = '\0';
  572. if (MonoClass::Is_Enabled()) {
  573. MonoClass *mono = MonoClass::Get_Current();
  574. if (!mono) {
  575. mono = new MonoClass();
  576. mono->View();
  577. }
  578. va_start(va, string);
  579. vsprintf(buffer, string, va);
  580. mono->Print(buffer);
  581. va_end(va);
  582. }
  583. return((short)strlen(buffer));
  584. }
  585. void Mono_Clear_Screen(void)
  586. {
  587. if (MonoClass::Is_Enabled()) {
  588. MonoClass *mono = MonoClass::Get_Current();
  589. if (!mono) {
  590. mono = new MonoClass();
  591. mono->View();
  592. }
  593. mono->Clear();
  594. }
  595. }
  596. void Mono_Text_Print(void const *text, int x, int y, int attrib)
  597. {
  598. if (MonoClass::Is_Enabled()) {
  599. MonoClass *mono = MonoClass::Get_Current();
  600. if (!mono) {
  601. mono = new MonoClass();
  602. mono->View();
  603. }
  604. mono->Text_Print((const char*)text, x, y, (char)attrib);
  605. }
  606. }
  607. void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick)
  608. {
  609. if (MonoClass::Is_Enabled()) {
  610. MonoClass *mono = MonoClass::Get_Current();
  611. if (!mono) {
  612. mono = new MonoClass();
  613. mono->View();
  614. }
  615. mono->Draw_Box(x, y, w, h, (char)attrib, (MonoClass::BoxStyleType)thick);
  616. }
  617. }
  618. void Mono_Print(void const *text)
  619. {
  620. if (MonoClass::Is_Enabled()) {
  621. MonoClass *mono = MonoClass::Get_Current();
  622. if (!mono) {
  623. mono = new MonoClass();
  624. mono->View();
  625. }
  626. mono->Print((const char*)text);
  627. }
  628. }
  629. int Mono_X(void)
  630. {
  631. if (MonoClass::Is_Enabled()) {
  632. MonoClass *mono = MonoClass::Get_Current();
  633. if (!mono) {
  634. mono = new MonoClass();
  635. mono->View();
  636. }
  637. return(short)mono->Get_X();
  638. }
  639. return(0);
  640. }
  641. int Mono_Y(void)
  642. {
  643. if (MonoClass::Is_Enabled()) {
  644. MonoClass *mono = MonoClass::Get_Current();
  645. if (!mono) {
  646. mono = new MonoClass();
  647. mono->View();
  648. }
  649. return(short)mono->Get_X();
  650. }
  651. return(0);
  652. }
  653. void Mono_Put_Char(char , int )
  654. {
  655. }
  656. void Mono_Scroll(int )
  657. {
  658. }
  659. void Mono_View_Page(int )
  660. {
  661. }
  662. #ifdef NEVER
  663. int Mono_Printf(int string, ...)
  664. {
  665. va_list va;
  666. char buffer[256];
  667. buffer[0] = '\0';
  668. if (MonoClass::Is_Enabled()) {
  669. MonoClass *mono = MonoClass::Get_Current();
  670. if (!mono) {
  671. mono = new MonoClass();
  672. mono->View();
  673. }
  674. va_start(va, string);
  675. vsprintf(buffer, Text_String(string), va);
  676. mono->Print(buffer);
  677. va_end(va);
  678. }
  679. return((short)strlen(buffer));
  680. }
  681. #endif