Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: "Randy Sorensen" , djgpp AT delorie DOT com Date: Mon, 9 Mar 1998 12:07:24 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Optimized code, comparing with Borland C++ 4.5 w/ Power Pack In-reply-to: <350334da.0@superego.idcomm.com> Precedence: bulk "Randy Sorensen" wrote > Subject: Optimized code, comparing with Borland C++ 4.5 w/ Power Pack > Date: Sun, 8 Mar 1998 17:01:04 -0700 > To: djgpp AT delorie DOT com > It probably goes without saying, but I'm somewhat of a newbie to gcc in > general, and especially DJGPP (used gcc on Linux a bit). So if this is a > dumb question, you'll just have to shoot me. > > I bought a book a few weeks ago called _Cutting Edge 3D Game Programming > with C++_ by John De Goes. The book has some nice texts on 3D coding, but > the way they did the sample code just plain sucks. The author used Borland > C++ 4.5, and also used Borland's PowerPack, two things that I don't own. > I'm not sure what the PowerPack does, but the code doesen't work with BC++ > 4.0 without it, and the folks on IRC say it doesen't work on 4.5 without the > PP either. It's DPMI code, and so I figured it would be pretty easy to port > it to DJGPP. As it turned out, it was. Which was nice, since code that > uses Borland's DPMI manager can only run on DOS (you have to shut down out > of Windows). Power Pack includes this DPMI thing that you say. > Here's my problem. When I do shut down out of DOS and run the exec's > included on the CD, they run up to 60 fps, where as the code that I ported > to DJGPP runs at 40 fps with the following optimizations: > "-O6 -ffast-math -funroll-loops -finline -m486". Is there any other > optimizations that will speed it up? Also, I've heard that using high > "-O"'s will cause problems.. should I bring it down to 4 or 3? Try: -O2 -ffast-math -fomit-frame-pointer > I should note that when I ported the code, the original author didn't do a > very "standard" job with it. Some of the matrix vector and point > transformation code was inlined (they were C++ methods) and I couldn't > figure out how to make DJGPP inline them. Probably the speed difference is here, for C++ methodes just put the code in the declaration of the class, like this: class X { int inline_member_example(int a) { return a+1; }; }; > Also, since you can't write to > video memory in DJGPP by default, I went about doing so using > __djgpp_nearptr_enable() and adding __djgpp_conventional_base to the video > memory address. Is there a faster way of going about video memory writing? Hmmmm.... I don't know what this code does but normally is faster to use a buffer in memory and then blit it to the screen because the normal memory is faster and most of the games writes more than ones the same pixel in the image (background then sprites, etc). > And lastly, I had to put some extra type-casts in there, since gcc.exe kept > giving me warnings about assigning doubles to unsigned char's and stuff. Well, assigning doubles to chars really needs a cast, it looks more like an error from the point of view of the compiler. SET ------------------------------------ 0 -------------------------------- Visit my home page: http://set-soft.home.ml.org/ or http://www.geocities.com/SiliconValley/Vista/6552/ Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013