www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/04/16:34:14

From: ey200 AT thor DOT cam DOT ac DOT uk (E. Young)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Full Source to untweaked MODE 0x13 Code
Date: 4 Feb 1997 19:10:16 GMT
Organization: University of Cambridge, England
Lines: 42
Message-ID: <5d81io$ohm@lyra.csx.cam.ac.uk>
References: <32e184e0 DOT 21986013 AT news DOT agate DOT net>
NNTP-Posting-Host: hammer.thor.cam.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

dgraf AT midcoast DOT com wrote:
: Just looking for 4 functions in inline asm.  Can someone enlighten me?
:   1 init mode 13h
:   2 plot a pixel
:   3 a screaming-fast copy  (like stosw)
:   4 init textmode 3

One thing to remember; DJGPP works in protected mode, so it's usually 
faster to do all your graphics in a virtual screen in extended memory
then blit it to the screen once per frame. On this assumption, I'd
write your functions thusly (in C, because there's no point in using 
asm for this stuff).

1)  
void SetVGA(){
   union REGS r;
   r.x.ax = 0x0013;
   int86(0x10, &r, &r);
}

2) Just plot the pixels to your virtual screen with 
inline void Putpixel(int x, int y, char Col){
   vaddr[x + y*SCREENX] = Col;
}
(gcc will optimise multiplication by 320 into some bizarre load
instruction, so this is pretty fast).

3) To copy to dos memory (eg the screen), use the dosmemput() 
   library function. Otherwise, use memcpy (which inlines to
   rep stosd anyway, I think).

4)  
void SetText(){
   union REGS r;
   r.x.ax = 0x0003;
   int86(0x10, &r, &r);
}

I don't know whether this is the absolute fastest you can do, but
it's pretty good. Good luck,

-Edwin

- Raw text -


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