home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!Germany.EU.net!unido!horga!ruhr.de!smallo.bo.open.de!oklein
- From: oklein@smallo.bo.open.de (Olaf Klein)
- Newsgroups: comp.lang.c
- Subject: Re: Curious bug...
- Message-ID: <1992Jul24.211127.23146@smallo.bo.open.de>
- Date: 24 Jul 92 21:11:27 GMT
- References: <1992Jul22.050021.3974@uwm.edu>
- Organization: smallo.bo.open.de Fido-SubNet-Gate : 2:245/5800.12
- Lines: 50
-
- pegasus@csd4.csd.uwm.edu (David R Hucke) writes:
-
- 1)
- >What happens is this: When I run the program in the QC Environment it
- >works fine. The characters are correct, and the colors are not correct.
- 2)
- >When I run the program from DOS (outside of the QC Environment) the characters
- >are correct but the colors are not correct.
-
- Wheres the difference between 1) and 2) ???
-
- >#include <stdio.h>
- >main()
- >{
- > short far *SCREEN = (short far *) 0xB8000000;
- > short menu[8][20];
- > short x,y;
- > FILE *file;
- > int i,j,z;
-
- > if(!(file = fopen("c:\\test.scn","r"))){
- > printf("Unable to open file!\n");
- > exit(99);
- > }
- > for(j=0;j<8;j++)
- > for(i=0;i<20;i++){
- > fscanf(file,"%c%c",&x,&y); /* reading in attribute and
- > character bytes */
- > menu[j][i] = (short)((y<<8)+x); /* putting together screen
- > character ---> attribute
- > and character. Shifting
- > one of the bytes. */
- > }
- > fclose(file);
- > for(j=0;j<8;j++)
- > for(i=0;i<20;i++)
- > *(SCREEN+((j+5)*80)+(30+i)) = (int)menu[j][i];
- >}
-
- I don't know the scope of a short in Quick-C, but if it's really
- 8-bits, which I could believe under DOS, then you loose the high
- (attribute) byte of menu[][], but get the char after the actual as the
- attribute char.
-
- Bye, Olaf
-
- PS. I don't think, that this program style is very portable, and the
- exit code doesn't match the errno-code, 2 (ENOENT) should be appropriate...
-
- --
- Olaf Klein smallo.bo.open.de 2:245/5800.12
-