void vgahost_shutdown (void) { #if defined (SAVE_VGA_STATE) if (vga_state != NULL) { /* Clean up the display, but only if we've done a mode set. * This makes sure that error messages don't get erased. */ if (vga_current_mode != NULL) restore_vga_state (); free (vga_state); vga_state = NULL; } #else if (vga_current_mode != NULL) restore_vga_state (); #endif }
boolean_t vgahost_init (int max_width, int max_height, int max_bpp, boolean_t fixed_p, int *argc, char *argv[]) { int sel; /* Grab a 64K selector for 0xA000:0000, for the frame buffer. */ sel = __dpmi_segment_to_descriptor (0xA000); if (sel == -1) return FALSE; vga_window_selector = sel; vga_screen_selector = -1; /* no value yet. */ vesa_version = compute_vesa_version (); #if defined (SAVE_VGA_STATE) #if !defined (USE_VESA_STATE_SAVE) state_glue_funcp = vga_state_glue; #else /* USE_VESA_STATE_SAVE */ #error "this will break with the mods to try switching to fullscreen and querying VESA version again...we might save the wrong kind of state!" if (vesa_version >= 0x100) /* version 1.0 or greater? */ state_glue_funcp = vesa_state_glue; else state_glue_funcp = vga_state_glue; #endif /* USE_VESA_STATE_SAVE */ #endif /* Save the current VGA state, so we can clean up well when we exit. */ save_vga_state (); /* WinNT appears to not show us a VESA driver unless we start in * full screen mode. However, if we set a plain VGA graphics mode * it switches us to full screen mode. If we didn't see a VESA * driver, this attempts to switch to fullscreen mode and then try * again. */ if (vesa_version == 0 && !only_use_vga_p) { __dpmi_regs regs; dpmi_zero_regs (®s); regs.x.ax = 0x12; /* 640x480 VGA mode. AH == 0x00. Erase screen. */ if (__dpmi_int (0x10, ®s) == 0) { vesa_version = compute_vesa_version (); restore_vga_state (); } } return TRUE; }
int set_current_console(int i) { if (i < 0 || i >= MAX_OSS) { return -1; } SCR_STATE.current = 0; save_vga_state(dosemu_regs); current_console = i; dosemu_regs = &all_dosemu_regs[current_console]; restore_vga_state(dosemu_regs); SCR_STATE.current = 1; return 0; }
static void restore_current_video(void) { if (!config.vga) return; /* After all that fun up there, get permissions and save/restore states */ if (video_initialized) { debug_vid("Restoring dosemu_regs[%d]\n", current_console); get_perm(); #ifdef WANT_DUMP_VIDEO dump_video(); #endif restore_vga_state(dosemu_regs); } }
/* Saves the vga state into vga_state, allocating space as necessary. */ static void save_vga_state (void) { __dpmi_regs regs; /* Fetch the current mode number. */ dpmi_zero_regs (®s); regs.h.ah = 0xF; if (__dpmi_int (0x10, ®s) != -1) orig_vga_mode = regs.h.al & 0x7F; else orig_vga_mode = -1; #if defined (SAVE_VGA_STATE) if (state_glue_funcp (COMPUTE_BUFFER_SIZE, &vga_state_size) && vga_state_size <= DOS_BUF_SIZE - DOS_MIN_STACK_SPACE && state_glue_funcp (SAVE_STATE, NULL)) { if (vga_state != NULL) free (vga_state); vga_state = malloc (vga_state_size); if (vga_state != NULL) { /* Save the state away in our memory space. */ movedata (dos_buf_selector, 0, dos_pm_ds, (unsigned) vga_state, vga_state_size); } } /* Restore the VGA state because many BIOSes corrupt it when they * save it (from the INTER document). This shouldn't be necessary * for VESA drivers, but it's conceivable some stupid VESA driver * calls one of the buggy BIOS routines which is known to need this. */ { int save_orig_mode; save_orig_mode = orig_vga_mode; orig_vga_mode = -1; /* Don't reset mode! */ restore_vga_state (); orig_vga_mode = save_orig_mode; } #endif }