home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / graphics / 8310 < prev    next >
Encoding:
Text File  |  1992-07-30  |  4.9 KB  |  159 lines

  1. Xref: sparky comp.graphics:8310 comp.os.msdos.programmer:8194
  2. Path: sparky!uunet!sun-barr!ames!agate!dog.ee.lbl.gov!network.ucsd.edu!cogsci!crl!hartung
  3. From: hartung@crl.ucsd.edu (Jeff Hartung)
  4. Newsgroups: comp.graphics,comp.os.msdos.programmer
  5. Subject: VESA Save/Restore SVGA state function...Problems
  6. Keywords: VESA SVGA Orchid Fahrenheit 1280 C MSDOS
  7. Message-ID: <1512@cogsci.ucsd.EDU>
  8. Date: 31 Jul 92 05:44:38 GMT
  9. Sender: news@cogsci.ucsd.EDU
  10. Followup-To: comp.os.msdos.programmer
  11. Distribution: na
  12. Organization: University of California, San Diego
  13. Lines: 144
  14.  
  15. I am trying to use the VESA SVGA BIOS extension subfunction 04h, that is
  16. supposed to save/restore the state of the SVGA to a buffer, or restore from
  17. information stored in a buffer.  As far as I can tell, I am using the function
  18. correctly, as the function calls are returning 4F in AL and 0 in AH, however,
  19. the result to my hardware (an Orchid Fahrenheit 1280) is that it gets locked
  20. in some weird state that cannot be undone, even by another call to reset the
  21. video state.  This happens even if I make the save and restore calls from the
  22. normal text mode (mode 3).
  23.  
  24. Part of the problem may be that I have a second graphics card, a Hercules
  25. clone, installed in my machine.  Orchid claims that the F1280 is only
  26. guaranteed to be compatible with a mono card that is "incapable of going into
  27. graphics mode."  However, this is one of the few times I have ever encountered
  28. any problem running anythning with both cards installed.  (I suppose that one
  29. way to test this would be to take out the other card...what a pain!)
  30.  
  31. However, since I am not particularly experienced in using this function,
  32. another explanation is that I am doing something wrong.  Here is the code I am
  33. using to do the job:
  34.  
  35. (Note:  I have edited out lots of other code that is unrelated to the problem,
  36. from what I can tell.  The actual program has a switch statement that lets the
  37. user test all 9 VESA functions from a menu.)
  38.  
  39. -------------
  40. #include <conio.h>
  41. #include <ctype.h>
  42. #include <dos.h>
  43. #include <mem.h>
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46.  
  47. #define VIDEO 0x10
  48. #define TEXT_MODE 3
  49. #define ESC 0x1B
  50.  
  51. /* function prototypes */
  52. int main(void);
  53. unsigned get_buff_size(void);
  54. int restore_state(char *buffer);
  55. int save_state(char *buffer);
  56. unsigned select_mode(void);
  57. char set_vesa_mode(unsigned mode);
  58. void set_bios_mode(unsigned char mode);
  59.  
  60. /* global variables */
  61. union REGS regs;
  62. struct SREGS sregs;
  63.  
  64. char set_vesa_mode(unsigned mode)
  65. {
  66.     regs.x.ax = 0x4f02;
  67.     regs.x.bx = mode;
  68.     int86(0x10, ®s, ®s);
  69.  
  70.     return regs.h.ah;
  71. }
  72.  
  73. void set_bios_mode(unsigned char mode)
  74. {
  75.     regs.h.ah = 0;
  76.     regs.h.al = mode;
  77.     int86(0x10, ®s, ®s);
  78. }
  79.  
  80. int save_state(char *buffer)
  81. {
  82.     regs.x.ax = 0x4f04;    /* Save/restore SVGA state function */
  83.     regs.h.dl = 1;        /* Save SVGA state function */
  84.     regs.x.cx = 0xf;    /* Save hardware, BIOS, DAC and SVGA state */
  85.     sregs.es = FP_SEG(buffer);
  86.     regs.x.bx = FP_OFF(buffer);
  87.     int86x(0x10, ®s, ®s, &sregs);
  88.  
  89.     return regs.x.ax;    /* Return status code in AX register */
  90. }
  91.  
  92. int restore_state(char *buffer)
  93. {
  94.     regs.x.ax = 0x4f04;    /* Save/restore SVGA state function */
  95.     regs.h.dl = 2;        /* Save SVGA state function */
  96.     regs.x.cx = 0xf;    /* Save hardware, BIOS, DAC and SVGA state */
  97.     sregs.es = FP_SEG(buffer);
  98.     regs.x.bx = FP_OFF(buffer);
  99.     int86x(0x10, ®s, ®s, &sregs);
  100.  
  101.     return regs.x.ax;    /* Return status code in AX register */
  102. }
  103.  
  104. int main(void)
  105. {
  106.     unsigned    mode, winsetval;
  107.     char         *buffer;
  108.     int        buff_size;
  109.     unsigned char    save_result, restore_result;
  110.  
  111.  
  112.     mode = select_mode();        /* User sets mode from stdin */
  113.     if (!set_vesa_mode(mode))
  114.     {
  115.         buff_size = get_buff_size();
  116.         buffer = malloc(buff_size);  /* Allocate memory for save info */
  117.         if (buffer != NULL)
  118.             save_result = save_state(buffer);
  119.         else
  120.             save_result = -1;
  121.         if (save_result == 0x4f)
  122.             restore_result = restore_state(buffer);
  123.         else
  124.             restore_result = -1;
  125.         if (buffer != NULL) free(buffer);
  126.     }
  127.     set_bios_mode(TEXT_MODE);
  128.     printf("Save/Restore buffer size was %d\n",
  129.         buff_size);
  130.     printf("Save state function returned %X\n",
  131.         save_result);
  132.     printf("Restore state function returned %X\n",
  133.         restore_result);
  134.     printf("\nValues of -1 or FF indicate that the");
  135.     printf(" function could not be performed.\n");
  136.     printf("Otherwise, value is returned value ");
  137.     printf("in AX register.  4F indicates success.\n");
  138.     break;
  139.  
  140.     clrscr();
  141.     return 0;
  142. }
  143. --------------
  144.  
  145. I am using BC++ 3.1 to compile the code (though I don't think that's the
  146. problem).  DOes anyone know what I might be doing wrong, or should I pull out
  147. the screwdriver and pull that #&$$#)&^ Hercules card out.  (Question:  How
  148. does Orchid expect me to debug a graphics program w/o a mono monitor.  As far
  149. as I can tell, there are no more plain old MDA cards being made out there any
  150. more.)
  151.  
  152. Thanks in advance for any and all suggestions,
  153.  
  154. -- 
  155.  --Jeff Hartung--      
  156.  Disclaimer: My opinions only, etc., etc., BLAH! BLAH! BLAH!...
  157.  InterNet - hartung@crl.ucsd.edu         BITNET - hartung@ucsd
  158.  UUCP - ucsd!crl.ucsd.edu!hartung
  159.