home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11589 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.8 KB  |  62 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!unido!horga!ruhr.de!smallo.bo.open.de!oklein
  2. From: oklein@smallo.bo.open.de (Olaf Klein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Curious bug...
  5. Message-ID: <1992Jul24.211127.23146@smallo.bo.open.de>
  6. Date: 24 Jul 92 21:11:27 GMT
  7. References: <1992Jul22.050021.3974@uwm.edu>
  8. Organization: smallo.bo.open.de Fido-SubNet-Gate : 2:245/5800.12
  9. Lines: 50
  10.  
  11. pegasus@csd4.csd.uwm.edu (David R Hucke) writes:
  12.  
  13. 1)
  14. >What happens is this:  When I run the program in the QC Environment it
  15. >works fine.  The characters are correct, and the colors are not correct.
  16. 2)
  17. >When I run the program from DOS (outside of the QC Environment) the characters
  18. >are correct but the colors are not correct.
  19.  
  20. Wheres the difference between 1) and 2)  ???
  21.  
  22. >#include <stdio.h>
  23. >main()
  24. >{
  25. >   short far *SCREEN = (short far *) 0xB8000000;
  26. >   short menu[8][20];
  27. >   short x,y;
  28. >   FILE *file;
  29. >   int i,j,z;
  30.  
  31. >   if(!(file = fopen("c:\\test.scn","r"))){
  32. >    printf("Unable to open file!\n");
  33. >    exit(99);
  34. >    }
  35. >    for(j=0;j<8;j++)
  36. >    for(i=0;i<20;i++){
  37. >           fscanf(file,"%c%c",&x,&y);    /* reading in attribute and
  38. >                         character bytes */
  39. >        menu[j][i] = (short)((y<<8)+x);  /* putting together screen
  40. >                        character ---> attribute
  41. >                        and character.  Shifting
  42. >                        one of the bytes. */
  43. >    }
  44. >    fclose(file);
  45. >    for(j=0;j<8;j++)
  46. >        for(i=0;i<20;i++)
  47. >        *(SCREEN+((j+5)*80)+(30+i)) = (int)menu[j][i];
  48. >}
  49.  
  50. I don't know the scope of a short in Quick-C, but if it's really
  51. 8-bits, which I could believe under DOS, then you loose the high
  52. (attribute) byte of menu[][], but get the char after the actual as the
  53. attribute char.
  54.  
  55. Bye, Olaf
  56.  
  57. PS. I don't think, that this program style is very portable, and the
  58. exit code doesn't match the errno-code, 2 (ENOENT) should be appropriate...
  59.  
  60. -- 
  61. Olaf Klein    smallo.bo.open.de    2:245/5800.12
  62.