1 /* Loglan82 Compiler&Interpreter
\r
2 Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw
\r
3 Copyright (C) 1993, 1994 LITA, Pau
\r
5 This program is free software; you can redistribute it and/or modify
\r
6 it under the terms of the GNU General Public License as published by
\r
7 the Free Software Foundation; either version 2 of the License, or
\r
8 (at your option) any later version.
\r
10 This program is distributed in the hope that it will be useful,
\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 GNU General Public License for more details.
\r
15 =======================================================================
\r
21 #define bound(x,y) ( x<0 || y<0 || x>719 || y>347 )
24 int pascal nocard( dummy )
31 #define index 0x3b4 /* 6845 ports */
33 #define mode 0x3b8 /* Herc ports */
41 static char *page_drawn;
42 static int page_drawn_no;
43 static int page_viewed;
47 #define HERC_BASE 0xE00B0000UL
48 #define CHAR_BASE 0xE00FFA6EUL
50 #define HERC_BASE 0xB0000000UL
51 #define CHAR_BASE 0xFFA6000EUL
55 static void set_page_drawn( page )
58 if( page == 0 || page == 1 )
60 page_drawn = (char *)( HERC_BASE + page * 0x8000);
66 static void screen_off()
68 outportb( mode, '\0' );
72 static void set_page_viewed( page )
75 if( page == 0 ) outportb( mode, '\x0a' );
77 if( page == 1 ) outportb( mode, '\x8a' );
82 static void clear_buffer( buf )
86 for( i=0; i<0x7fff; i++ ) buf[i] = '\0';
90 static void clear_gr_scr( page )
93 if( page_viewed == page ) screen_off();
94 clear_buffer( (char *)(HERC_BASE + page*0x8000) );
95 if( page_viewed == page ) set_page_viewed( page );
99 static int in_graphics=0;
100 void pascal gron( dummy )
104 static char params[16] = {
105 '\x35', '\x2d', '\x2e', '\x07', '\x5b', '\x02',
106 '\x57', '\x57', '\x02', '\x03', '\x00', '\x00',
107 '\x00', '\x00', '\x00', '\x00'
110 if( in_graphics ) return;
119 if (( AX & 0x30 ) == 0x30)
120 for (i=0; i<0x800; i++)
121 if (inportb(status) & 0x80)
128 fprintf( stderr, "This version runs only with HERCULES graphic card\n" );
135 outportb( config, 3 ); /* allows both graphics pages */
137 for( i=0; i<sizeof(params); i++) {
138 outportb( index, i );
139 outportb( data, params[i] );
141 set_page_viewed( 0 );
142 set_page_drawn ( 0 );
154 static char params[16] = {
155 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06,
156 0x19, 0x19, 0x02, 0x0d, 0x0b, 0x0c,
157 0x00, 0x00, 0x00, 0x00
160 if( !in_graphics ) return;
163 outportb( config, 0 ); /* lock out graphics mode */
165 for( i=0; i<sizeof(params); i++) {
166 outportb( index, i );
167 outportb( data, params[i] );
169 outportb( mode, '\x28' ); /* enable blink and turn on screen */
173 void pascal hpage( nr, tryb, zeruj )
174 int *nr,*tryb,*zeruj;
178 if( *zeruj ) clear_gr_scr( 0 );
179 if( *tryb == 1 ) set_page_viewed( 0 );
180 if( *tryb == -1 ) set_page_viewed( 0 );
185 if( *zeruj ) clear_gr_scr( 1 );
186 if( *tryb == 1 ) set_page_viewed( 1 );
187 if( *tryb == -1 ) set_page_viewed( 1 );
192 void pascal video( buffer )
202 if( page_viewed == page_drawn_no ) clear_gr_scr( page_viewed );
203 else clear_buffer( page_drawn );
207 void pascal point( col, row )
211 int byte_ofs; /* offset within page for byte containing the point */
212 char mask; /* locates point within the byte */
213 if( bound( *col, *row ) ) return;
214 mask = 1 << (7 - (x % 8));
215 byte_ofs = 0x2000 * (y % 4) + 90 * (y/4) + (x/8);
216 if( cur_color == 1 ) /* draw the point */
217 page_drawn[ byte_ofs ] |= mask;
218 else /* erase the point */
219 page_drawn[ byte_ofs ] &= ~mask;
224 void pascal move( col, row )
232 int pascal inxpos( dummy ) void *dummy; { return cur_x; }
233 int pascal inypos( dummy ) void *dummy; { return cur_y; }
236 int pascal inpix( col, row )
240 int byte_ofs; /* offset within page for byte containing the point */
241 char mask; /* locates point within the byte */
242 if( bound( *col, *row ) ) return 0;
244 mask = 1 << (7 - (x % 8));
245 byte_ofs = 0x2000 * (y % 4) + 90 * (y/4) + (x/8);
246 return !!( page_drawn[ byte_ofs ] & mask );
250 void pascal color( c )
257 void pascal intens( intensity ) int *intensity; {}
258 void pascal pallet( palette ) int *palette; {}
259 void pascal border( color ) int *color; {}
260 void pascal style ( style_no ) int *style_no; {}
261 void pascal patern( p1,p2,p3,p4 ) int *p1,*p2,*p3,*p4; {}
264 static struct { int x,y,c; } stack[16];
265 static int stack_top=0;
268 stack[stack_top ].x = cur_x;
269 stack[stack_top ].y = cur_y;
270 stack[stack_top++].c = cur_color;
274 cur_x = stack[--stack_top].x;
275 cur_y = stack[ stack_top].y;
276 cur_color = stack[ stack_top].c;
280 void pascal track ( x, y ) int *x,*y; {}
282 static char *char_base = (char *)CHAR_BASE;
283 void pascal hascii( chrp )
287 int chr = (*chrp) & 0x7F;
288 int x00 = inxpos(NULL);
289 int y00 = inypos(NULL);
295 for( i=x00; i<x00+8; i++ ) for( j=y00; j<y00+8; j++ ) point(&i,&j);
300 char *c = char_base + 8*chr;
301 for( i=x00; i<x00+8; i++ ) for( j=y00; j<y00+8; j++ )
302 if( !!( c[j-y00] & (0x80>>(i-x00)) ) )
312 void pascal hfont ( seg, ofs ) int *seg,*ofs; {}
313 void pascal hfont8( seg, ofs ) int *seg,*ofs; {}