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.
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: mono.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
17 #pragma on (unreferenced)
19 // Library functions for printing to mono card.
31 #pragma aux mono_int_3 = "int 3";
33 #define MAX_NUM_WINDOWS 2
36 unsigned char character;
37 unsigned char attribute;
48 struct mono_element save_buf[25][80];
49 struct mono_element text[25][80];
53 void scroll( short n );
54 void drawbox( short n );
56 #define ROW Window[n].first_row
57 #define HEIGHT Window[n].height
58 #define COL Window[n].first_col
59 #define WIDTH Window[n].width
60 #define CROW Window[n].cursor_row
61 #define CCOL Window[n].cursor_col
62 #define OPEN Window[n].open
63 #define CHAR(r,c) (*monoscreen)[ROW+(r)][COL+(c)].character
64 #define ATTR(r,c) (*monoscreen)[ROW+(r)][COL+(c)].attribute
65 #define XCHAR(r,c) Window[n].text[ROW+(r)][COL+(c)].character
66 #define XATTR(r,c) Window[n].text[ROW+(r)][COL+(c)].attribute
70 int Mono_initialized = 1;
73 static WINDOW Window[MAX_NUM_WINDOWS];
75 struct mono_element (*monoscreen)[25][80];
77 void mputc( short n, char c )
81 // if (keyd_pressed[KEY_BACKSP])
90 CHAR( CROW, CCOL ) = ' ';
91 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
92 XCHAR( CROW, CCOL ) = ' ';
95 CHAR( CROW, CCOL ) = ' ';
96 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
97 XCHAR( CROW, CCOL ) = ' ';
107 CHAR( CROW, CCOL ) = c;
108 ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
109 XCHAR( CROW, CCOL ) = c;
113 if ( CCOL >= WIDTH ) {
117 if ( CROW >= HEIGHT ) {
122 msetcursor( ROW+CROW, COL+CCOL );
126 void mputc_at( short n, short row, short col, char c )
138 void copy_row(int nwords,short *src, short *dest1, short *dest2 );
139 #pragma aux copy_row parm [ecx] [esi] [ebx] [edx] modify exact [eax ebx ecx edx esi] = \
148 "even_num: cmp ecx, 0" \
150 "rowloop: mov eax, [esi]" \
160 void scroll( short n )
167 for ( row = 0; row < (HEIGHT-1); row++ )
168 copy_row( WIDTH, (short *)&XCHAR(row+1,col), (short *)&CHAR(row,col), (short *)&XCHAR(row,col) );
170 // for ( col = 0; col < WIDTH; col++ )
172 // CHAR( row, col ) = XCHAR( row+1, col );
173 // ATTR( row, col ) = XATTR( row+1, col );
174 // XCHAR( row, col ) = XCHAR( row+1, col );
175 // XATTR( row, col ) = XATTR( row+1, col );
178 for ( col = 0; col < WIDTH; col++ )
180 CHAR( HEIGHT-1, col ) = ' ';
181 ATTR( HEIGHT-1, col ) = XATTR( HEIGHT-1, col );
182 XCHAR( HEIGHT-1, col ) = ' ';
187 void msetcursor(short row, short col)
189 int pos = row*80+col;
192 outp( 0x3b5, pos & 0xFF );
194 outp( 0x3b5, (pos >> 8) & 0xff );
197 static char temp_m_buffer[1000];
198 void mprintf( short n, char * format, ... )
200 char *ptr=temp_m_buffer;
205 va_start(args, format );
206 vsprintf(temp_m_buffer,format,args);
212 void mprintf_at( short n, short row, short col, char * format, ... )
215 char buffer[1000], *ptr=buffer;
225 va_start(args, format );
226 vsprintf(buffer,format,args);
233 msetcursor( ROW+CROW, COL+CCOL );
238 void drawbox(short n)
244 for (row=0; row <HEIGHT; row++ ) {
245 CHAR( row, -1 ) = 179;
246 CHAR( row, WIDTH ) = 179;
247 XCHAR( row, -1 ) = 179;
248 XCHAR( row, WIDTH ) = 179;
251 for (col=0; col < WIDTH; col++ ) {
252 CHAR( -1, col ) = 196;
253 CHAR( HEIGHT, col ) = 196;
254 XCHAR( -1, col ) = 196;
255 XCHAR( HEIGHT, col ) = 196;
259 CHAR( -1, WIDTH ) = 191;
260 CHAR( HEIGHT, -1 ) = 192;
261 CHAR( HEIGHT, WIDTH ) = 217;
262 XCHAR( -1,-1 ) = 218;
263 XCHAR( -1, WIDTH ) = 191;
264 XCHAR( HEIGHT, -1 ) = 192;
265 XCHAR( HEIGHT, WIDTH ) = 217;
269 void mclear( short n )
275 for (row=0; row<HEIGHT; row++ )
276 for (col=0; col<WIDTH; col++ ) {
292 for (row=-1; row<HEIGHT+1; row++ )
293 for (col=-1; col<WIDTH+1; col++ ) {
305 void mrefresh(short n)
311 for (row=-1; row<HEIGHT+1; row++ )
312 for (col=-1; col<WIDTH+1; col++ ) {
313 CHAR(row,col) = XCHAR(row,col);
314 ATTR(row,col) = XATTR(row,col);
317 msetcursor( ROW+CROW, COL+CCOL );
322 int mono_present(); //return true if mono monitor in system
325 void mopen( short n, short row, short col, short width, short height, char * title )
329 if (!Mono_initialized) return; //error! no mono card
339 for (row=-1; row<HEIGHT+1; row++ )
340 for (col=-1; col<WIDTH+1; col++ ) {
351 msetcursor( ROW+CROW, COL+CCOL );
355 #pragma aux mono_present value [eax] modify [bx] = \
370 static initialized=0;
373 if (!Mono_initialized) {
374 for (n=0; n<MAX_NUM_WINDOWS; n++ ) {
383 return 0; //error! no mono card
391 monoscreen = (struct mono_element (*)[25][80])0xB0000;
404 for (n=1; n<MAX_NUM_WINDOWS; n++ ) {
414 return -1; //everything ok