delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/21/04:52:09

Xref: news2.mv.net comp.os.msdos.djgpp:4074
From: jlouwere AT galaxy DOT csc DOT calpoly DOT edu (Jan Louwerens)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Making the nearptr hacks use longs.
Date: 20 May 1996 21:43:35 GMT
Organization: Cal Poly Computer Science Dept.
Lines: 43
Message-ID: <4nqp27$8uu@waldorf.csc.calpoly.edu>
References: <4nqe0f$som AT geraldo DOT cc DOT utexas DOT edu>
NNTP-Posting-User: jlouwere AT galaxy DOT csc DOT calpoly DOT edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Austin Appleby            (a.k.a. Tanjent) (applea AT weiss DOT che DOT utexas DOT edu) wrote:
: unsigned long *videoptr = (unsigned long *)0xA0000;
: unsigned char buff[320*200];
: unsigned long *sbuffptr = &char[0];


: dumpscrn() {
:    int i;
:    __djgpp_nearptr_enable();
:    for(i=0;i<320*50;i++)  {
:       videoptr[4*i + __djgpp_conventional_base] = sbuffptr[i];
:       }
:    __djgpp_nearptr_disable();
:    }


This doesn't look very speedy to me. The near pointer enabling and disabling
is slow. (I prefer to do it once at the beginning and end of my program, not
once per frame.) Also, the (320*50) must be calculated for every iteration
of the loop, as well as the (4*i) and the add. Why not just make an inline
assembler function to do it. That seems fastest to me. Something like:

	mov	esi, (pointer to Virtual Screen)
	mov	edi, (pointer ~csc/sample/ada/to VGA Memory)
	mov	ecx, 16000	(320*200 / 4 (for ~csc/sample/ada/dwords))
	rep
	movsl

(This code may not be exactly correct, but it gets the idea across)
--
                                           _____  ___________
                                          |\    \|\          \
  _____  _____                            | \    \ \     _____\
 |\    \|\    \                           \  \    \ \    \    |
 | \    \ \    \                         _____\    \ \    \______
 \  \    \ \    \                       |\          \ \          \
  \  \    \ \    \                      | \_____     \ \     _____\
 _____\    \ \    \_____                \ |     \     \ \    \    |
|\          \ \         \                \|______\     \ \    \___|
| \__________\ \_________\                 |\           \ \    \
\ |          | |         |                 | \___________\ \____\
 \|__________|\|_________|                 \ |           | |    |
                                            \|___________|\|____|

- Raw text -


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