home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:8310 comp.os.msdos.programmer:8194
- Path: sparky!uunet!sun-barr!ames!agate!dog.ee.lbl.gov!network.ucsd.edu!cogsci!crl!hartung
- From: hartung@crl.ucsd.edu (Jeff Hartung)
- Newsgroups: comp.graphics,comp.os.msdos.programmer
- Subject: VESA Save/Restore SVGA state function...Problems
- Keywords: VESA SVGA Orchid Fahrenheit 1280 C MSDOS
- Message-ID: <1512@cogsci.ucsd.EDU>
- Date: 31 Jul 92 05:44:38 GMT
- Sender: news@cogsci.ucsd.EDU
- Followup-To: comp.os.msdos.programmer
- Distribution: na
- Organization: University of California, San Diego
- Lines: 144
-
- I am trying to use the VESA SVGA BIOS extension subfunction 04h, that is
- supposed to save/restore the state of the SVGA to a buffer, or restore from
- information stored in a buffer. As far as I can tell, I am using the function
- correctly, as the function calls are returning 4F in AL and 0 in AH, however,
- the result to my hardware (an Orchid Fahrenheit 1280) is that it gets locked
- in some weird state that cannot be undone, even by another call to reset the
- video state. This happens even if I make the save and restore calls from the
- normal text mode (mode 3).
-
- Part of the problem may be that I have a second graphics card, a Hercules
- clone, installed in my machine. Orchid claims that the F1280 is only
- guaranteed to be compatible with a mono card that is "incapable of going into
- graphics mode." However, this is one of the few times I have ever encountered
- any problem running anythning with both cards installed. (I suppose that one
- way to test this would be to take out the other card...what a pain!)
-
- However, since I am not particularly experienced in using this function,
- another explanation is that I am doing something wrong. Here is the code I am
- using to do the job:
-
- (Note: I have edited out lots of other code that is unrelated to the problem,
- from what I can tell. The actual program has a switch statement that lets the
- user test all 9 VESA functions from a menu.)
-
- -------------
- #include <conio.h>
- #include <ctype.h>
- #include <dos.h>
- #include <mem.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #define VIDEO 0x10
- #define TEXT_MODE 3
- #define ESC 0x1B
-
- /* function prototypes */
- int main(void);
- unsigned get_buff_size(void);
- int restore_state(char *buffer);
- int save_state(char *buffer);
- unsigned select_mode(void);
- char set_vesa_mode(unsigned mode);
- void set_bios_mode(unsigned char mode);
-
- /* global variables */
- union REGS regs;
- struct SREGS sregs;
-
- char set_vesa_mode(unsigned mode)
- {
- regs.x.ax = 0x4f02;
- regs.x.bx = mode;
- int86(0x10, ®s, ®s);
-
- return regs.h.ah;
- }
-
- void set_bios_mode(unsigned char mode)
- {
- regs.h.ah = 0;
- regs.h.al = mode;
- int86(0x10, ®s, ®s);
- }
-
- int save_state(char *buffer)
- {
- regs.x.ax = 0x4f04; /* Save/restore SVGA state function */
- regs.h.dl = 1; /* Save SVGA state function */
- regs.x.cx = 0xf; /* Save hardware, BIOS, DAC and SVGA state */
- sregs.es = FP_SEG(buffer);
- regs.x.bx = FP_OFF(buffer);
- int86x(0x10, ®s, ®s, &sregs);
-
- return regs.x.ax; /* Return status code in AX register */
- }
-
- int restore_state(char *buffer)
- {
- regs.x.ax = 0x4f04; /* Save/restore SVGA state function */
- regs.h.dl = 2; /* Save SVGA state function */
- regs.x.cx = 0xf; /* Save hardware, BIOS, DAC and SVGA state */
- sregs.es = FP_SEG(buffer);
- regs.x.bx = FP_OFF(buffer);
- int86x(0x10, ®s, ®s, &sregs);
-
- return regs.x.ax; /* Return status code in AX register */
- }
-
- int main(void)
- {
- unsigned mode, winsetval;
- char *buffer;
- int buff_size;
- unsigned char save_result, restore_result;
-
-
- mode = select_mode(); /* User sets mode from stdin */
- if (!set_vesa_mode(mode))
- {
- buff_size = get_buff_size();
- buffer = malloc(buff_size); /* Allocate memory for save info */
- if (buffer != NULL)
- save_result = save_state(buffer);
- else
- save_result = -1;
- if (save_result == 0x4f)
- restore_result = restore_state(buffer);
- else
- restore_result = -1;
- if (buffer != NULL) free(buffer);
- }
- set_bios_mode(TEXT_MODE);
- printf("Save/Restore buffer size was %d\n",
- buff_size);
- printf("Save state function returned %X\n",
- save_result);
- printf("Restore state function returned %X\n",
- restore_result);
- printf("\nValues of -1 or FF indicate that the");
- printf(" function could not be performed.\n");
- printf("Otherwise, value is returned value ");
- printf("in AX register. 4F indicates success.\n");
- break;
-
- clrscr();
- return 0;
- }
- --------------
-
- I am using BC++ 3.1 to compile the code (though I don't think that's the
- problem). DOes anyone know what I might be doing wrong, or should I pull out
- the screwdriver and pull that #&$$#)&^ Hercules card out. (Question: How
- does Orchid expect me to debug a graphics program w/o a mono monitor. As far
- as I can tell, there are no more plain old MDA cards being made out there any
- more.)
-
- Thanks in advance for any and all suggestions,
-
- --
- --Jeff Hartung--
- Disclaimer: My opinions only, etc., etc., BLAH! BLAH! BLAH!...
- InterNet - hartung@crl.ucsd.edu BITNET - hartung@ucsd
- UUCP - ucsd!crl.ucsd.edu!hartung
-