delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/23/16:06:18

From: Ludvig Larsson <ludvig AT club-internet DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GPF when trying to access VGA adapter
Date: Tue, 23 Jun 1998 21:40:46 +0100
Organization: FAAS/GoldHart
Lines: 74
Message-ID: <359004BE.5BB3@club-internet.fr>
References: <Pine DOT SOL DOT 3 DOT 95 DOT 980617235959 DOT 21339B-100000 AT tiger DOT vut DOT edu DOT au>
Reply-To: ludvig AT club-internet DOT fr
NNTP-Posting-Host: toulouse1-146.club-internet.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi Owen, yes, they are right, read the manual.
But, I didn't found the answers as fast as I wished
when I wrote myself my graphic code(I had for one example, 
an old faq...)

Use this to set the mode and the bank:

(uses  include <dpmi.h>  I think)

int set_bank(int bank)
{
 __dpmi_regs reg;
 if(bank!=active_bank)
  {
   reg.h.ah=0x4f;
   reg.h.al=0x05;
   reg.h.bh=0x00;
   reg.h.dl=bank;
   reg.h.dh=0;
   __dpmi_int(0x10,&reg);
   active_bank=bank;
  }
 return(0);
}

int setmode(short mode)
{
 int ret;
 __dpmi_regs reg;
 __dpmi_meminfo mi;
 int vesa_err;
 reg.x.ax=0x4f02;
 reg.x.bx=mode;
 __dpmi_int(0x10,&reg);
 ret=reg.x.ax;
 if(mode=0x111)
  {
    reg.x.ax=0x4f06;
    reg.h.bl=0x00;   /* Set scan line length */
    reg.x.cx=640;    /* desired width in pixels */
    __dpmi_int(0x10, &reg);
    ret=reg.x.cx;    /* nr of pixels/scanline */
  }
 return(ret);
}


And here is a codesnippet (uncomplete, but you might be able
to figure out how you can access the A0000+64kb area):

void plot16(int x,int y,unsigned int col)
{
 int b;
 int offset=plot16_y[y]+x<<1;
 b=offset>>16;
 offset=(offset&0x0000FFFF)+0xA0000;
 if((x>=0)&&(x<640)&&(y>=0)&&(y<480))
  {
   if(b!=active_bank)
    set_bank(b);
   _farpokew(_dos_ds,offset,col);
  }
}

It's taken out of my home made graphic package and uses a 
lookuptable and a 16bit 640x480 res, but don't bother about
that, look at the _farpoke thing, it "pokes" at absolute
dos adresses(Watch out, there are better ways=more secure ways,
when debugging, check that 'offset' always are between A0000 and
AFFFF, the VGA window, and all should work fine).

Hope it helps.

Ludvig Larsson

- Raw text -


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