delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/10/19:35:54

From: Carl B <carlb AT frugal DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Linear Success!
Date: Thu, 10 Jul 1997 08:47:17 -0700
Organization: A Red Hat Linux Site
Lines: 55
Message-ID: <33C50405.3FC8@frugal.com>
References: <33C4B1E4 DOT 740D AT frugal DOT com>
Reply-To: carlb AT frugal DOT com
NNTP-Posting-Host: ts0110.frugal.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Carl B wrote:
> 
> Hi,
>  I can't figure out how to enable Linear Addressing for the Trident 9440
> chip.  Apparently "port : 0x3D4, index 0x21, bit 5" has to be set to
> enable Linear Addressing and I can't get it to set.  I have a Pentium
> 75Mhz w/24Mb of EDO memory and 1Mb of video memory, I'm compiling in DOS
> with DJGPP's 32-bit Protected Mode C++ compiler.  Any help would be
> greatly appreciated!
> 
>                  Thanks,
>                     Carl B. (mailto:carlb AT frugal DOT com)
Hi,
 It's me again.  I finally figured out how to use Trident's Linear
Address.  Thanks to everyone for their input.  I'm including the code I
came up with to implement the buffer access in the hopes that other
people can use it.


------------------------------------------------------------------------ 
                 
#include <sys/farptr.h>
#include <dpmi.h>


  TrLinearInfo.size=(ulong)TrCfgRec.VideoMemory; // Total Video Memory
(1Mb)
  TrLinearInfo.address=0xF0000000; // MemBase (from setpci.exe, in
archive -> ua64-dos.exe)
  unsigned char* ScrPtr = (unsigned char*)
malloc((long)TrLinearInfo.size); // Allocate Linear Buffer
  __djgpp_map_physical_memory(ScrPtr, TrLinearInfo.size,
TrLinearInfo.address); // Map Linear Address To Buffer

 unsigned short width=640, height=480;

 unsigned char* Buf = (unsigned char*) malloc((long)width*height);

 for(counter=0; counter < (long)(width*height); counter++)
  Buf[counter] = 2;  // Paint Source Buffer Green

  _farsetsel(_my_ds()); // Set Selector

  SetVidMode(0x5D); // Initiate Graphics Mode (640x480 256 Colors)

  for(counter=0; counter < (long)(width*height); counter++)
  _farnspokeb(ScrPtr+counter, Buf[counter]);          // Put Source
Buffer into Linear Buffer

   getkey(); // Wait For KeyPress

   SetVidMode(0x03); // Restore Text Mode

  free(ScrPtr); // Free Up Linear Buffer
  free(Buf);    // Free Up Source Buffer

- Raw text -


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