delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/07/13:01:01

Newsgroups: comp.os.msdos.djgpp
From: Elliott Oti <blamspam_oti AT fys DOT ruu DOT nl>
Subject: Re: Help with mode 13h and the video buffer
Sender: usenet AT fys DOT ruu DOT nl (News system Tijgertje)
Message-ID: <343A2428.41C6@fys.ruu.nl>
Date: Tue, 7 Oct 1997 11:59:36 GMT
References: <Pine DOT SUN DOT 3 DOT 95 DOT 971007024155 DOT 22179A-100000 AT lurch-fddi>
Mime-Version: 1.0
Organization: Subatomaire Fysica, RUU
Lines: 59
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

H. Anthony Hoyt wrote:
> 
> Hey guys,
>      I'm a newbie to protected mode (with djgpp) but not to real mode
> with C/C++.  What I need help on is with writeing the contents to a
> secondary buffer to the video buffer in mode 13h (Address 0xa0000 I think)
> Now let's say I have a variable called double_buffer that is specified as
> follows:
> 
> char double_buffer[64000];
> 
> now if I want to copy this array to the video buffer (defined as:
> char * video_buffer = (char *) 0xa0000; ) and prior to that I called the
> following function
> 
> void init_video(void) {
>      __djgpp_nearptr_enable();
>      video_buffer += __djgpp_conventional_base;
>      __djgpp_nearprt_disable();
> }
> 
> Then will I be able to use the following function to copy double_buffer
> to the video buffer?
> 
> void show_db(void) {
>      wait_for_vsync();
>      __djgpp_nearptr_enable();
>      memcpy((char *)video_buffer,(char *)double_buffer,64000);
>       __djgpp_nearptr_disable();
> }
> 
>      Well, Please let me know before my computer lets me know and I'm
> pulling my hair out of my head.  If this is not enough info, let me know.
>  Thanks
> 
>                                            Tony
> 
> May you find strength in magic -- RavenHart  @}->--'--,---

You should not call nearptr_disable() until you're finished with 
video_buffer. That turns on memory protection again, so what you're
doing is simply:
 1. Turn off protection
 2. Get linear video address
 3. Turn on protection again, defeating the purpose of step two because
AFAIK __djgpp_conventional_base is not neccessarily constant across
calls to __djgpp_nearptr_disable() (I don't know how likely this is,
tho').
 4. With a possibly invalid video pointer you call memcpy.

The rest looks good.
BTW don't hesitate to experiment. The average question posted may get
you 10 different answers; the only way to know if your code will truly
crash is to compile and run it.

-- 
  Elliott Oti
  kamer 104, tel (030-253) 2516 (SAP)    
  http://www.fys.ruu.nl/~oti

- Raw text -


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