www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/22/05:22:18

Date: Sun, 22 Dec 1996 12:36:47 +0200 (EET)
From: Indrek Mandre <indrek AT warp DOT edu DOT ee>
To: Mike Pope <dt AT inreach DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Slow code and SVGALib
In-Reply-To: <32BC29D9.7036@inreach.com>
Message-ID: <Pine.LNX.3.91.961222112522.118A-100000@warp.edu.ee>
MIME-Version: 1.0

On Sat, 21 Dec 1996, Mike Pope wrote:
> Hi all...
> Could somebody PLEASE tell me why this code is so danged SLOW?
> I've tried everything I could think of!  Basically, what I'm trying
> to do is write a scrolling routine with SVGALib, but it's so dang slow.
> I'm essentially using SVGALib as nothing more than a pointer
> to video memory and I wrote my own blast functions and everything.
> For those of you wondering why I'm mucking around with SVGALib
> instead of something nice like Allegro, I need portability to  Linux.
> (For those of you who suggest GRX and JLib, I can't get JLib to compile
> and GRX seems essentially useless :) ).  I'm using a 486DX/50
> with 8 megs of RAM and a TSeng ET4000 video board.  

Yes, SVGALIB is one of the finest librarys I know and it's very fast also
because it supports almost all video cards directly and it's simple.
I recommend you look at the demo programmes before starting programming,
there is a lot you should know. And do you have the newest library?
README and README.gl are helpful.

> 
> /*Fodder.c - my program.*/
> #include <vga.h>
> #include <vgagl.h>
> #include <vgakeybo.h>

Here should be vgakeyboard.h because in linux it wont compile...

> #define NUMBALLS 50
> #define SCRWIDTH 352
[deleted]
> 
> void rawblt(int x, int y, unsigned char *dest, unsigned char *source, int 
> srcwidth, int srcheight) 
> {
> 	int i, j;
> 	source+=(y*SCRWIDTH+x);
> 	for (j=0;j<200;j++) {
> 		for (i=0;i<320;i++) {
> 			*dest=*source;
> 			dest++;
> 			source++;
> 		}
> 		source+=32;
> 	}	
> }

Try it so (I hope it works):

int j;
 source += y * SCRWIDTH + x;
 for ( j=0; j<200; j++ ) {
	memcpy ( dest, source, 320 );
	dest += 320;
	source += SCRWIDTH;
 }

You have one problem - why don't you use memcpy? That what you are
doing is slow. Moving byte after byte style will not get you anywhere.
The same problem on all your blitting funcs...

>
[deleted]
> I'm awfully sorry that it's so sloppy but I didn't anticipate this
> kind of problem as it was intended as nothing more than a simple
> demo to see what I could do with it.
> 
> gl_putbox() is the built-in blitting function, but I can't seem
> to get it to work.  This is the error message it produces when I 
> compile it with gl_putbox() in it:
> D:\DJGPP\CODE\SVGALIB>gcc -Wall fodder.c -o fodder -lvga -lvgagl
> fodder.c: In function `do_balls':
> fodder.c:96: warning: unused variable `j'
> fodder.c: In function `main':
> fodder.c:125: warning: unused variable `j'
> fodder.c:124: warning: unused variable `i'
> grlib.c(.text+0x11ee): undefined reference to `vga_copytoplanar256'
> grlib.c(.text+0x1281): undefined reference to `vga_copytoplanar16'
> grlib.c(.text+0x12da): undefined reference to `vga_copytoplanar16'
> grlib.c(.text+0x1341): undefined reference to `vga_copytoplanar16'
> driver.c(.text+0x328): undefined reference to `vga_accel'
> driver.c(.text+0x333): undefined reference to `vga_accel'
> driver.c(.text+0xbef): undefined reference to `vga_accel'
> driver.c(.text+0x3406): undefined reference to `vga_copytoplanar256'
> ...And the library is compiled with everything, so I can't
> fathom the problem.  Any ideas at all?  I'm completely stumped.
> This slowdown is there a lot without the balls too, so I
> think it's rawblt(), which is used to transfer the virtual screen
> to the video pointer.  Also, is there any way to assure it runs
> in mode 13h and would run on any other VGA system?
> Any help you can give me on any of this would be greatly appreciated.
> Back to your regularly scheduled news broadcast...

You compile in a wrong order, you should do it so:
gcc -Wall fodder.c -o fodder -lvgagl -lvga
You wrote your nice blittings but why did you waste your time. Look
at vgagl's sources - there are your nice putboxparts, why didn't you
use them? Hint: there is a demo program on scrolling - scrolltest.c.
When you want use higher resolutions, you have to deal with bank
switching. You also may use that fancy linear framebuffer but for example
my card doesn't support it when computer has more than 14 Mb RAM (I have 16).
If you are a beginner use vgagl with it's virtual screens. It will do all
the job for you and is fast.

Indrek
indrek AT warp DOT edu DOT ee

PS: I didn't have luck to compile your source on my Linux... For example 
    conio.h isn't part of linux. Use real vgakeyboard. If you make your 
    programmes under Linux they mostly will compile under DJGPP but from DOS 
    to Linux it's awful.

- Raw text -


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