home *** CD-ROM | disk | FTP | other *** search
- /* set_mode.c -- main program to set video mode on the IBM PC
-
- **************** Copyright 1984 by Vince Taylor ******************
-
- USAGE
-
- To set the video mode on the IBM PC and to initialize the
- color/graphics display adapter when both adapters are installed.
-
- FUNCTION
-
- Requests user to enter mode code.
-
- Places proper value in bits 5 and 6 of EQUIP_FLAG, located at
- 40:10, in the BIOS data area by first reading EQUIP_FLAG and
- then replacing bits 5 & 6 (out of 8) with the following values:
-
- Mode Bits 6 and 5 Display
-
- 0 - 1 0 1 (40x25)
- 2 - 3 1 0 (80x25)
- 4 - 6 1 0 graphics
- 7 1 1 (80x25)
-
- The flag value determines the initial display mode, which
- is always black and white, but may be either 40 or 80
- columns. In this routine, we will never see the initial
- (default) display because we immediately set the mode to
- the one requested by the user. The equipment flag is
- relevant because it is used by the BIOS mode-set routine
- and will create an error unless properly set. (It also seems
- to be used by some other part of BIOS, because as soon
- as the flag value is changed to indicate another type
- of display card, before the mode is formally
- changed, output disappears from the currently active
- screen.)
-
- The flag value needs to be changed if we want to change
- from the mono adapter to the color/graphics adapter,
- because the IBM BIOS always sets the flag for the mono card
- (mode 7) if both are installed, and the value of the flag
- is used by the BIOS mode- set routine (INT 10H, function 0)
- to determine whether the mono or color/graphics board
- addresses are to be used. Thus, to allow switching from
- one adapter to the other, we change the flag setting to
- indicate the adapter card corresponding to the mode
- selected. (We could use either 01 binary or 10 binary for
- bits 5 and 6 for all color/graphics display modes. We use
- the two value simply to remain consistent with parameter
- values used by the BIOS for the initialization sequence.)
-
- Calls VID_INT with AH = 0 and AL = mode value to set the
- display mode to the one selected by the user.
-
- CALL
-
- set_mode()
-
- RETURNS
-
- = mode value.
-
- CAUTIONS
-
- This program will NOT operate properly only under UNIX systems
- since it makes use of hardware features of MSDOS systems.
-
- */
-
- /* #define WN_DEBUG Commented out when debugged */
- #include <wfc.h>
- #include <wfc_glob.h>
-
- main()
- {
- int mode;
- int kval;
- WINDOW wn; /*window for display */
-
- init_wfc(); /*initialize the WFC system */
- defs_wn(&wn,0,0,20,40,&bdr_dln); /*initialize window */
- sav_wi(&wn);
- set_wn(&wn);
- for(;;)
- {
- cl_wn(&wn);
- v_st("Modes available for selection are:\n\n", &wn);
- v_st(" Mode Mode Number \n", &wn);
- v_st(" Graphics Board \n", &wn);
- v_st(" 40x25 B&W 0 \n", &wn);
- v_st(" 40x25 Color 1 \n", &wn);
- v_st(" 80x25 B&W 2 \n", &wn);
- v_st(" 80x25 Color 3 \n", &wn);
- v_st(" Graphics Modes\n" , &wn);
- v_st(" 320x200 Color 4 \n", &wn);
- v_st(" 320x200 B&W 5 \n", &wn);
- v_st(" 640x200 B&W 6 \n", &wn);
- v_st(" Monochrome Board 7 \n\n", &wn);
- wn.att = NORMAL + HIGH_INT;
- v_st("Please type mode number: ", &wn);
- pl_csr(&wn);
- mode = ki();
- wn.c = 0; /*put cs at beginning of row */
- v_qch(' ',wn.ce - wn.cb + 1, &wn); /*erase row (cs does not move) */
- v_st("Mode selected is ",&wn); /*rewrite message */
- v_rw(mode,1,&wn);
- wn.att = NORMAL;
- v_st("\n\nPress Escape to cancel entry, any other key to proceed.", &wn);
- pl_csr(&wn);
- if((kval =ki()) == 27) continue;
- if(kval == -1) /*control-break exit */
- {
- unset_wn(&wn);
- mv_csr(23,0,&wn0);
- exit(0);
- }
- if((mode -= 48) >= 0 && mode <= 7)
- break; /*legitimate number, continue */
- wn.c = 0; /*else go back and try again */
- }
- unsav_wi(&wn);
- vid_mode(mode);
- return(0);
- }