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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
15 * Library functions for printing to mono card.
19 // Library functions for printing to mono card.
30 //#define MONO_IS_STDERR
33 #pragma aux mono_int_3 = "int 3";
35 static inline void mono_int_3() { asm("int $3"); }
37 void msetcursor(short row, short col);
39 #define MAX_NUM_WINDOWS 2
42 unsigned char character;
43 unsigned char attribute;
54 struct mono_element save_buf[25][80];
55 struct mono_element text[25][80];
59 void scroll( short n );
60 void drawbox( short n );
62 #define ROW Window[n].first_row
63 #define HEIGHT Window[n].height
64 #define COL Window[n].first_col
65 #define WIDTH Window[n].width
66 #define CROW Window[n].cursor_row
67 #define CCOL Window[n].cursor_col
68 #define OPEN Window[n].open
69 #define CHAR(r,c) (*monoscreen)[ROW+(r)][COL+(c)].character
70 #define ATTR(r,c) (*monoscreen)[ROW+(r)][COL+(c)].attribute
71 #define XCHAR(r,c) Window[n].text[ROW+(r)][COL+(c)].character
72 #define XATTR(r,c) Window[n].text[ROW+(r)][COL+(c)].attribute
74 static WINDOW Window[MAX_NUM_WINDOWS];
76 struct mono_element (*monoscreen)[25][80];
78 void mputc( short n, char c )
82 // if (keyd_pressed[KEY_BACKSP])
91 CHAR( CROW, CCOL ) = ' ';
92 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
93 XCHAR( CROW, CCOL ) = ' ';
96 CHAR( CROW, CCOL ) = ' ';
97 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
98 XCHAR( CROW, CCOL ) = ' ';
108 CHAR( CROW, CCOL ) = c;
109 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
110 XCHAR( CROW, CCOL ) = c;
114 if ( CCOL >= WIDTH ) {
118 if ( CROW >= HEIGHT ) {
123 msetcursor( ROW+CROW, COL+CCOL );
127 void mputc_at( short n, short row, short col, char c )
139 void copy_row(int nwords,short *src, short *dest1, short *dest2 );
140 #pragma aux copy_row parm [ecx] [esi] [ebx] [edx] modify exact [eax ebx ecx edx esi] = \
149 "even_num: cmp ecx, 0" \
151 "rowloop: mov eax, [esi]" \
160 void copy_row(int nwords,short *src, short *dest1, short *dest2 ) {
162 *(dest1++) = *(dest2++) = *(src++);
166 void scroll( short n )
168 register int row, col;
173 for ( row = 0; row < (HEIGHT-1); row++ )
174 copy_row( WIDTH, (short *)&XCHAR(row+1,col), (short *)&CHAR(row,col), (short *)&XCHAR(row,col) );
176 // for ( col = 0; col < WIDTH; col++ )
178 // CHAR( row, col ) = XCHAR( row+1, col );
179 // ATTR( row, col ) = XATTR( row+1, col );
180 // XCHAR( row, col ) = XCHAR( row+1, col );
181 // XATTR( row, col ) = XATTR( row+1, col );
184 for ( col = 0; col < WIDTH; col++ )
186 CHAR( HEIGHT-1, col ) = ' ';
187 ATTR( HEIGHT-1, col ) = XATTR( HEIGHT-1, col );
188 XCHAR( HEIGHT-1, col ) = ' ';
193 void msetcursor(short row, short col)
195 int pos = row*80+col;
198 outp( 0x3b5, pos & 0xFF );
200 outp( 0x3b5, (pos >> 8) & 0xff );
203 static char temp_m_buffer[1000];
204 void _mprintf( short n, char * format, ... )
206 #ifdef MONO_IS_STDERR
208 va_start(args, format );
209 vfprintf(stderr, format, args);
211 char *ptr=temp_m_buffer;
216 va_start(args, format );
217 vsprintf(temp_m_buffer,format,args);
223 void _mprintf_at( short n, short row, short col, char * format, ... )
226 char buffer[1000], *ptr=buffer;
236 va_start(args, format );
237 vsprintf(buffer,format,args);
244 msetcursor( ROW+CROW, COL+CCOL );
249 void drawbox(short n)
255 for (row=0; row <HEIGHT; row++ ) {
256 CHAR( row, -1 ) = 179;
257 CHAR( row, WIDTH ) = 179;
258 XCHAR( row, -1 ) = 179;
259 XCHAR( row, WIDTH ) = 179;
262 for (col=0; col < WIDTH; col++ ) {
263 CHAR( -1, col ) = 196;
264 CHAR( HEIGHT, col ) = 196;
265 XCHAR( -1, col ) = 196;
266 XCHAR( HEIGHT, col ) = 196;
270 CHAR( -1, WIDTH ) = 191;
271 CHAR( HEIGHT, -1 ) = 192;
272 CHAR( HEIGHT, WIDTH ) = 217;
273 XCHAR( -1,-1 ) = 218;
274 XCHAR( -1, WIDTH ) = 191;
275 XCHAR( HEIGHT, -1 ) = 192;
276 XCHAR( HEIGHT, WIDTH ) = 217;
280 void mclear( short n )
286 for (row=0; row<HEIGHT; row++ )
287 for (col=0; col<WIDTH; col++ ) {
303 for (row=-1; row<HEIGHT+1; row++ )
304 for (col=-1; col<WIDTH+1; col++ ) {
316 void mrefresh(short n)
322 for (row=-1; row<HEIGHT+1; row++ )
323 for (col=-1; col<WIDTH+1; col++ ) {
324 CHAR(row,col) = XCHAR(row,col);
325 ATTR(row,col) = XATTR(row,col);
328 msetcursor( ROW+CROW, COL+CCOL );
333 int mono_present(); //return true if mono monitor in system
336 void mopen( short n, short row, short col, short width, short height, char * title )
340 if (! mono_present()) return; //error! no mono card
350 for (row=-1; row<HEIGHT+1; row++ )
351 for (col=-1; col<WIDTH+1; col++ ) {
360 _mprintf( n, title );
362 msetcursor( ROW+CROW, COL+CCOL );
367 #pragma aux mono_present value [eax] modify [bx] = \
378 int mono_present() { return 0; }
384 static int initialized=0;
387 if (! mono_present()) return 0; //error! no mono card
394 monoscreen = (struct mono_element (*)[25][80])0xB0000;
407 for (n=1; n<MAX_NUM_WINDOWS; n++ ) {
417 return -1; //everything ok