home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / msdos / programm / 11654 < prev    next >
Encoding:
Text File  |  1992-12-28  |  2.5 KB  |  92 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!utcsri!skule.ecf!torn!pulp.cs.laurentian.ca!paul
  3. From: paul@ramsey.cs.laurentian.ca (Paul Lalonde)
  4. Subject: Need help with hires bitmapping/storage in C/asm
  5. Message-ID: <1992Dec28.082618.8705@ramsey.cs.laurentian.ca>
  6. Organization: Dept. of Computer Science, Laurentian University, Sudbury, ON
  7. Date: Mon, 28 Dec 1992 08:26:18 GMT
  8. Lines: 82
  9.  
  10. I just finished a tiny TSR program in C (activated by ALT-*) that grabs
  11. the 64K of bitmap data at A000:0000 in hires mode 320x200x256colours.
  12. It sends this 64k to a file called 'output.bin'. The purpose of this TSR
  13. is to grab the graphics screen under Deluxe Paint so that I can use my
  14. screens in my own programs. The TSR works.
  15.  
  16. However, when I use another program, DISPLAY.C, to read in the binary file
  17. output.bin and display it back on the 320x200x256 screen, the colours are
  18. mismatched.
  19.  
  20. I'm only a neophyte assembly programmer, but I'm assuming this is a result
  21. of 16->8 bit truncation during register MOVes and fputc()/fgetc() operations.
  22.  
  23. I'm "enclosing" the code snippet from the TSR that dumps the video screen,
  24. as well as the display program.
  25.  
  26. I would appreciate any help in getting both the TSR dumper to dump the
  27. proper binary image and the displayer to read the proper image.
  28.  
  29. Thanks for any help!
  30.  
  31. --TSR 320x200x256colour video screen dumper function--
  32.  
  33. void dumpvideo(void)
  34. {
  35.      unsigned int i;
  36.      FILE *fp;
  37.      unsigned char ch;         
  38.      
  39.      fp = fopen("\\output.bin", "wb");
  40.          if (fp == NULL) return(0);
  41.  
  42.      asm mov cx, 0A000h;
  43.      asm mov es, cx;
  44.      asm mov di, 0;
  45.  
  46.      for(i=0; i<64000; i++){
  47.         asm mov ax, [byte ptr es:di];
  48.         asm inc di;
  49.         fputc(_AX, fp);
  50.      }
  51.      fclose(fp);
  52.  
  53. }
  54.  
  55. --displayer program--
  56.  
  57. #include <stdio.h>
  58.  
  59. void main(void)
  60. {
  61.         FILE *fp;
  62.         unsigned i;
  63.         unsigned char ch;
  64.  
  65.         fp = fopen("output.bin", "rb");
  66.         if(fp==NULL) exit();
  67.  
  68.         asm mov ah, 0;
  69.         asm mov al, 13h;
  70.         asm int 10h;
  71.         asm mov cx, 0A000h;
  72.         asm mov es, cx;
  73.         asm mov di, 0;
  74.  
  75.         for(i=0; i<64000; i++){
  76.                 _AX = fgetc(fp);
  77.                 asm mov [es:di], ax;
  78.                 asm inc di;
  79.         }
  80.         fclose(fp);
  81.         getch();
  82.         asm mov ah, 0;
  83.         asm mov al, 3;
  84.         asm int 10h;
  85. }
  86.                 
  87. -- 
  88. ------------------------------------+-----------------------------------------
  89. Paul Lalonde, Dept. of CompSci      |  "C'mon baby, don't fear the Reaper"
  90. Laurentian University - Sudbury/ONT |                           -B.O.C.
  91. ----'83-Mustang-GT-5.0L--&--RUSH----+-----------------------------------------
  92.