-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAKEBADR.C
55 lines (45 loc) · 1.12 KB
/
MAKEBADR.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Programma "MAKEBADR.C"
* Crea le tabelle Badr[] per i diversi modi grafici nelle sotto-dir
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
unsigned int Badr[400] ;
void main(int argc, char ** argv)
{
FILE * f ;
char fname[80] ;
register int y ;
int size ;
printf("MakeBadr: crea una tabella di indirizzi per la grafica\n") ;
if (argc<=1) {
fprintf(stderr,"USO: MakeBadr <scheda grafica> ...\n") ;
fprintf(stderr,"schede supportate: ATT, CGA\n") ;
exit(1) ;
}
for ( argv++; --argc; argv++ ) {
strcpy(fname,*argv) ;
strcat(fname,"\\badr.byt") ;
f = fopen (fname, "wb") ;
if (!f) {
fprintf(stderr,"Invalid specification: <%s>\n",*argv) ;
exit(2) ;
}
if (!stricmp(*argv,"att")) {
for (y=0; y<=399; Badr[y++]= ((y&3)<<13)+80*(y>>2)) /*NOP*/ ;
size = 400 ;
} else if (!stricmp(*argv,"cga")) {
for (y=0; y<=199; Badr[y++]= ((y&1)<<13)+80*(y>>1)) /*NOP*/ ;
size = 200 ;
} else {
fprintf(stderr,"Unrecognized device: <%s>\n",*argv) ;
exit(1) ;
}
if ( size != fwrite( Badr, sizeof(unsigned int), size, f ) ) {
perror("Error on writing") ;
exit(1) ;
}
}
}