]> icculus.org git repositories - btb/d2x.git/blob - unused/win95/winmono.c
Import of d2x-0.0.8
[btb/d2x.git] / unused / win95 / winmono.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: winmono.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
17 #pragma on (unreferenced)
18
19
20 #include <windows.h>
21 #include <malloc.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <stdarg.h>
25 #include <string.h>
26
27
28 static int                              WinMonoInitialized = 0;
29 static HANDLE                   hConOutput = 0;
30
31
32
33 //      ----------------------------------------------------------------------------
34 //      Functions
35 //      ----------------------------------------------------------------------------
36
37 int minit(void)
38 {
39
40         if (WinMonoInitialized) return 1;
41
42         if (!AllocConsole()) return 0;
43         hConOutput = GetStdHandle(STD_OUTPUT_HANDLE);
44         if (hConOutput == INVALID_HANDLE_VALUE) return 0;
45
46         WinMonoInitialized = 1;
47         
48         return 1;
49
50 }
51
52 int mkill(void)
53 {
54         FreeConsole();
55
56         return 1;
57 }
58
59
60 void mopen(short n, short row, short col, short width, short height, char *title)
61 {
62         if (!WinMonoInitialized) return;
63 }
64                 
65
66 void mclose(int n)
67 {
68         if (!WinMonoInitialized) return;
69 }       
70
71
72 void msetcursor(short row, short col)
73 {
74         COORD coord;
75
76         coord.X =  col;
77         coord.Y =  row;
78
79         SetConsoleCursorPosition(hConOutput, coord);
80 }
81
82
83 void mputc(short n, char c)
84 {
85         char buf[2];
86         DWORD chwritten;
87
88         if (!WinMonoInitialized) return;
89
90         buf[0] = c; buf[1] = 0;
91
92         WriteConsole(hConOutput, buf, 1, &chwritten,  NULL); 
93 }
94
95
96 void mputc_at(short n, short row, short col, char c)
97 {
98         if (!WinMonoInitialized) return;
99         
100         msetcursor(row,col);
101
102         mputc(n, c);
103 }
104
105
106 void scroll(short n)
107 {
108 }               
109
110
111 static char temp_m_buffer[1000];
112
113 void mprintf(short n, char *format, ...)
114 {
115         char *ptr = temp_m_buffer;
116         va_list args;
117         DWORD chwritten;
118         
119         if (!WinMonoInitialized) return;
120
121         va_start(args, format);
122         vsprintf(temp_m_buffer, format, args);
123         WriteConsole(hConOutput, ptr, strlen(ptr), &chwritten, NULL); 
124 }
125
126
127 void mprintf_at(short n, short row, short col, char *format, ...)
128 {
129         char *ptr = temp_m_buffer;
130         va_list args;
131         DWORD chwritten;
132         
133         if (!WinMonoInitialized) return;
134
135         va_start(args, format);
136         vsprintf(temp_m_buffer, format, args);
137         msetcursor(row, col);
138         WriteConsole(hConOutput, ptr, strlen(ptr), &chwritten, NULL); 
139 }
140         
141
142 void drawbox(short n)
143 {
144 //      Obsolete in the New Order
145 }
146
147
148 void mrefresh(short n)
149 {
150 //      Huh??? :)
151 }
152