delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/25/09:30:22

Date: Fri, 25 Mar 1994 9:06:04 -0500 (EST)
From: "Chris Mr. Tangerine Man Tate" <FIXER AT FAXCSL DOT DCRT DOT NIH DOT GOV>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Per request - video-mode interrupt stuff

A number of people on this list have asked me about my trials and tribulations
involving video mode switching, so I'm just going to write a little summary
here of how to manage it.

My particular application uses 80 column by 50 row mode, so the code I'm
about to post just remembers the 'current' mode, switches into 80x50, and
restores the previous mode.

I'm no expert on PC-architecture video, but the following seems to work
fine.

----- begin code -----

static unsigned char old_mode;

void switch_to_80x50(void)
{
    union REGS reg;

    reg.h.ah = 0x0F;             // 'read video mode' selector
    int86(0x10, &reg, &reg);     // execute the INT 10 call
    old_mode = reg.h.al;         // current video mode returned in reg.h.al

// Now create 80x50 mode - really 80x25 with an 8x8 font
//
// This code is extracted from the DJGPP source file gppconio.c

    reg.h.ah = 0x00;             // 'set video mode' selector
    reg.h.al = 0x03;             // standard 80x25 mode
    int86(0x10, &reg, &reg);     // switch!

    reg.h.ah = 0x12;             // enabling cursor emulation
    reg.h.bl = 0x34;
    reg.h.al = 0x00;             // 0: enable, 1: disable
    int86(0x10, &reg, &reg);

// The next bit gets 50 columns by switching to the use of 8x8 characters.
// Ralf Brown's interrupt list indicates that this is a Realtek RTVGA call,
// but it seems to work fine on my Trident 8900, and indeed is the way
// that the DJGPP gppconio.c emulation of the Turbo C graphics library
// handles it.

    reg.x.ax = 0x1112;           // set ROM 8x8 characters
    reg.x.bx = 0;
    int86(0x10, &reg, &reg);
}

// This routine restores the saved video mode

void restore_old_mode(void)
{
    union REGS reg;

    reg.h.ah = 0x00;             // 'set mode' selector
    reg.h.al = old_mode;         // mode stored previously
    int86(0x10, &reg, &reg);
}

----- end code -----

The full list of PC-architecture interrupts and what they're used for can
be obtained from the SIMTEL MS-DOS archive or any of its mirrors.  I
personally like oak.oakland.edu, but wuarchive.wustl.edu also mirrors it,
as do several other sites around the world.

On oak.oakland.edu, the interrupt list is in /pub/msdos/info, and the files
are called inter39*.zip.  This list is *huge* - I printed out just the
portion dealing with video modes, and it's a stack of about 50 pages,
densely written.  Electronic searching for what you're looking for is
the way to go.  :-)

---------------------------------------------------------------------
Christopher Tate             |   "Blue ice cubes?  How degenerate!"
MSD, Inc.                    |
fixer AT faxcsl DOT dcrt DOT nih DOT gov    |    < anybody recognize the source? >

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019