#Public Demo Thread
10 messages in this thread
Jeff,
I'm sick of posting this stuff in the "irony" thread. Let's start our own
thread for this "public demo" group, even if it does just turn out to be the
two of us. You'll note I've already done this.
> Yes, exactly, I fiqure the extra calcs on a few points (for aspect
> adjustments) would be quicker than the slower pixel writes in Mode-X. Of
> course if there are any very complex objects, things could slow down.
Well, let's discuss this Mode-X thing a little. I've heard it said that
Mode-X is slower than Mode 13h on many occasions. Although there is some truth
in this, I think that it's less true than many people think.
From my pespective, there are 3 major reasons that Mode-X might be
slower than Mode 13h:
1. "Standard" Mode-X is 320×240 while Mode 13h is 320×200.
More pixels, more time. Yeah, true (duh!) but in that case, how about 80×50
text mode? You could still do 16 colors, and that would be BLINDING fast! Oh,
it's lower resolution? Too bad! Let's forget this one. Besides, if you want,
there is a 320×200 X-Mode too (supported in my XUNIT).
2. Mode-X is slower because of the need to set the mask register with OUTS
to select which pixel of the 4 you want to write.
This one is true, but it's only a big problem if you program it stupidly. I
couldn't believe that Michael Abrash, who first wrote the articles in Doctor
Dobb's Journal which got everyone started on Mode-X, missed this obvious
optimization himself, and freely admits in in a recent PC Techniques.
If you program it stupidly by using (for example) the XPutPix routine from my
library to draw every pixel, then the frame rate will be DOG-slow. This is
because, to fill an entire screen, you do 76800 OUTs per screen, plus all the
multiplies and shifts etc. required to figure out which bit needs to be set.
Especially because of the slow PC bus, this drags everything down dramatically.
The alternative is drawing the screen in vertical stripes, reducing
the number of OUTs to 320 per screen. This is pretty manageable, and
doesn't slow things down that badly at all. This is the way the XVert
routine in XUNIT works, by the way.
In addition (as I think you know), you can get speedups out of
Mode-X if you have multiple pixels in a row that are the same color,
since you can set up to 8 at a time with a single 16-bit OUT (yes,
*8* at a time, not 4!). Of course, you have to do so much
pre-processing to decide if this can be done, it may not be worth it.
It also lets out being able to do texture-mapping or Gouroud shading,
so this ability is probably only of minimal usefulness.
However, if you think about it, it DOES really speed up a full-screen clear,
and you'll notice that my XClrScr and XClrVal routines make use of this. (I
don't take credit for these, they come directly from the Abrash articles). For
some things, though (like a DOOM-type game for example), clearing the screen
between frames isn't necessary, since you re-write every pixel on the screen
for every frame anyway, so once again it just depends on what you're doing.
3. You can't do 16-bit writes in Mode-X, only 8-bits, so since just about
everyone has a 16-bit card these days, this slows you down by 2X. In Mode
13h, you can put 2 adjacent 8-bit pixel values into AX and OUT them both at
once.
This one's tougher, but I THINK I have an answer for it. It works on my
Cirrus card, but I don't know if it works on all VGA's. Anybody who has any
knowledge of this is welcome to rebut me …
Actually, you CAN load 2 8-bit pixel values into AL and AH, then OUT them
both at once. The only problem is that they will come out 4 pixels apart from
each other. This is relatively ugly, BUT …
Suppose you build your picture in RAM like the standard 320×200 offscreen
buffer. Then you can simply organize the pixels such that you can later
transfer them from RAM to screen in 16-bit chunks because they've already been
organized 4-pixels apart when they were written to the offpage buffer.
"But," I hear the skeptics say, "now you've bought all the problems of Mode
13. Why bother with Mode-X at all if you're not going to do page flipping in
Mode-X or 4-pixel at a time page-to-page transfers?"
Two reasons: 1:1 aspect ratio, and higher X-Mode resolutions (there are
several cool 256-color alternative resolutions, including 376×282 and 400×300).
If you're trying to so spherical texture-mapping, you'll find that the 1.2:1
ratio is a giant pain in the butt.
> Wu??? Is it an optimized Bresenham's? Or a completely new approach to line
> draws?
The latter. If you can lay your hands on a copy of Graphics Gems (the first
one), it's described on page 101. Or, the Aug/Sept issue of PC Techniques has
an article on Wu's algorithm (page 73), though it's an extension of the basic
algorithm that also does on-the-fly anti-aliasing.
> Right now I want to draw a 3D globe
There's a great demo called "Planets" available on the Internet, which
features 3 texture-mapped planets bouncing around on the screen and rotating in
real-time. This demo also includes the source code (in C of course), and a
detailed tutorial which goes into the math he used.
I've got a (fairly) good implementation of his algorithm in Pascal, and I've
added scaling the bitmap. It uses my XUNIT library (of course) and includes an
algorithm which darkens the bitmap as a function of the direction the light
hits the globe. If you're interested, I could upload either or both of these.
Let me know. I've also got a cheezy cobbled-together "land-mass generator"
which attempts to make Earth-type world bitmaps built in.
> I had been thinking of this myself as well, the other advantage to triangles
> is that they are always triangles no matter how they're rotated in 3 space
> (except on edge, where they become lines), as opposed to squares, which
> become trapesoids. This means that you can build a triangle engine which
> would work in all situations.
Just a thought. Maybe it would be worthwhile building a REALLY optimized
triangle generator and then just using solids that lend themselves well to this
type of engine. It could always be expanded to arbitrary polygons later.
Also, while on this subject, FYI, the spherical texture-mapper I discussed
before uses a lookup table, not a polygon or triangle engine. This makes it
blazing fast, but limits the directions you can rotate the sphere when viewing
it.
> How's your "water" stuff coming along. I used to be a chem major, so if
> you need any reference materials (I have a CRC among other things) let
> me know.
Thanks for the offer, but I have a buddy who's a major chem fan and has loads
of reference material on the subject. I suppose I could upload it the way it is
now, since the side-file is just a "trajectory table" which contains the
positions of the atoms versus time, much like the tables used in spaceship
flybys in many demos. I guess it's a "legal" way to write a demo. It also has
the advantage of being able to play back several chemical animation files,
including a fairly cool salt crystal in addition to the water molecule.
The one problem you might have is … didn't you say you have only a 286? It
will run on that, but it only runs at 7 frames per second on a 386/16. It will
probably be slower yet on a 286, depending on the speed. However, I guess if
you had a choice, you'd have upgraded by now, right? It peps along at 30 frames
per second on my 486/66, and at 60fps on a Pentium/VLB.
Regards,
Fred Trafton
Fred,
> BORDERS? Where the heck are you? The only Border's Books I know of is in
Dallas. <
Well, there's one in Mt. Lebanon –just outside of Pittsburgh. Before Barnes
and Noble opened it was the only book store that had computer books besides the
"How to use ….", et al. (except of course for the campus bookstores at Pitt,
CMU, etc.). I don't know if these are part of a chain, but Border's Books is
the only book store I know of with a fireplace, comfy chairs (no one expects
the Spannish Inquisition <g> –sorry, I've seen too much Monty Python) and FREE
coffee to make your book browsing experience as pleasant as possible. Sure
beats the "Are you going to buy that?" approach to customer service.
> Well, let's discuss this Mode-X thing a little. <
Thanks for your insights, I haven't ruled out mode-X, but I think I'll first
optimize my 3D "stuff", and then proceed to tweak the video.
> There's a great demo called "Planets" available on the Internet…. <
I think I saw that here, and it didn't "appreciate" my '286.
> I've got a (fairly) good implementation of his algorithm in Pascal….
It uses my XUNIT library (of course) and includes an algorithm which
darkens the bitmap as a function of the direction the light hits the
globe. If you're interested…. Let me know. I've also got a cheezy
cobbled-together "land-mass generator" which attempts to make
Earth-type world bitmaps built in. <
Sure I'm interested, it isn't exactly what I want (but then it wouldn't be any
fun, if there wasn't any work <g>). I can use the Pascal code, but I'll hold
off on the C for now. Even if I don't use the code, I may give me some ideas
and start me thinking in new and different directions.
> Just a thought. Maybe it would be worthwhile building a REALLY optimized >
triangle generator and then just using solids that lend themselves well to >
this type of engine. It could always be expanded to arbitrary polygons later.
YES, I'm thinking of putting a satalite in obit around my planet, and I'll try
and build it out of triangles. The globe has some obvious symetry that I don't
want to overlook (I figure that I can calculate normals for only 1/8 of the
facets, and then just change the sines –sort of like building a sine look up
table for just the first quadrant, and applying it to both sine and cos for ALL
angles).
> Also, while on this subject, FYI, the spherical texture-mapper I discussed
> before uses a lookup table, not a polygon or triangle engine. This makes it >
blazing fast, but limits the directions you can rotate the sphere when viewing
> it.
I was thinking about the LUT approach, but decided that I wanted full freedom
of movement. I'm considering making my demo "interactive", in order to prove
that it's being generated in real time. What I'll probably do is generate a
plasma cloud (one which "wraps" from left to right), add ice caps to the poles
and distort it for texture mapping (sqish the x-values as y gets further from
the equator). The globe will be faceted, but I think (hope) it will still
appear "mostly" round.
You can UL or mail your PASCAL planet stuff, like I said, even if I don't use
it, there still may be plenty of useful ideas.
Well, you decide when your demo is finished, I don't think that a pregenerated
motion "script" wouldn't be legal. You could always generate it at start up
while you have a scrolly with your name, etc. go by.
> The one problem you might have is … didn't you say you have only a 286? >
It will run on that, but it only runs at 7 frames per second on a 386/16. It >
will probably be slower yet on a 286, ….
Slower is an improvement to: ERROR 386 Req'd
> I guess if you had a choice, you'd have upgraded by now, right?
Choice, money, etc. I'm looking into those CPU upgrades. 486SXs may be
getting cheaper, but I need to keep my FPU –and I can't afford a DX :(.
Jeff,
P.S. Like I said, you decide on how you want to send it, but I AM
interested in your Pascal goodies.
Jeff,
Yep, your Border's sounds just like ours. I guess it must be a chain. And
they don't even rag on you for reading the books there without buying.
I'll upload my PASCAL implementation of the PLANETS algorithm. It's not too
bad, though a bit slow being all in Pascal. Next weekend I'll try to get the
files together that are needed and upload source and .EXE files.
Sorry about the DX being out of reach. How about a 386 motherboard with one
of those Cyrix chips (DLC I think) that make it "sort of" a 486 but without the
copro? You may still get faster speed with 486 emulation of the copro than a
"real" 287 FPU. I dunno, never seen a benchmark.
Oh well, one thing I'll say – if you can get a decent frame rate on a 286, it
should really BLAZE on a fast machine! <g>
Regards,
Fred Trafton
Fred,
> Yep, your Border's sounds just like ours. I guess it must be a chain. And >
they don't even rag on you for reading the books there without buying.
I guess they are a chain, it's nice to find someone who believes in service.
> I'll upload my PASCAL implementation of the PLANETS algorithm. It's not too
> bad, though a bit slow being all in Pascal. Next weekend I'll try to get the
> files together that are needed and upload source and .EXE files.
I'll look for them, maybe I'll try my hand at some in-line asm to speed things
up.
> Sorry about the DX being out of reach. How about a 386 motherboard with one
> of those Cyrix chips (DLC I think) that make it "sort of" a 486 but without >
the copro? You may still get faster speed with 486 emulation of the copro >
than a "real" 287 FPU. I dunno, never seen a benchmark.
I've thought of the motherboard swap, unfortunately my PC is an AMSTRAD with an
unuaual case design. It's actually quite nice, but I don't think it'll take a
"clone" motherboard. There are a few '286 CPU upgrades that use the CYRIX SLC
chip, or the IBM Blue Lightning (up to 90 MHz) and will let me use my CYRIX
FastMath Co-Pro. Several programs (including MSD) detect it as a 387 and it'll
run at speeds of up to 20 MHz. I'm still looking into it.
> Oh well, one thing I'll say – if you can get a decent frame rate on a 286,
> it should really BLAZE on a fast machine! <g>
I figure that it'll make me work harder for tighter code, of course my idea of
"decent frame rate" is different from yours (I can accept 5-10 fps). I've got a
video benchmark program that rates my system a crummy <4 fps (needless to say I
don't rate their polygon engine very highly <g>).
Jeff
>>I'm looking into those CPU upgrades. 486SXs may be<<
I was looking at those for the 386SX I do telcom on. Instead I got an IBM SLC66
motherboard with a copro and 4 megs of RAM for $400. The copro's not nearly as
fast as my DX2-66, but many ops benchmark faster on the IBM.
The recent PC Mag overview of those upgrade things said "don't."
Dan,
> I was looking at those for the 386SX I do telcom on. Instead I got an IBM >
SLC66 motherboard with a copro and 4 megs of RAM for $400. The copro's not >
nearly as fast as my DX2-66, but many ops benchmark faster on the IBM.
Unfortunately, my system case is a bit odd. Once I buy a new case, a new power
supply, a new video card (mine's part of the motherboard), the price leaves my
range. I've found an upgrade that uses the IBM SLC chip for about $250. I can
then slowly build to my system with new hard drive, fast VGA card, etc. at a
pace I can afford.
> The recent PC Mag overview of those upgrade things said "don't."
I saw that. Did you read the fine print. They did seem to like the '386
upgrades (sort of, at least they didn't hate them as much as they hated the
'486 clock doublers). I think that those magazine people spend too much time
with P-90s and the like to realize that some of us would settle for a 5-10 X
improvement. Did you notice that they ignored the '286 upgrades because
"nobody uses THOSE things anymore.
<Choice, money, etc. I'm looking into those CPU upgrades. 486SXs may be
getting cheaper, but I need to keep my FPU –and I can't afford a DX :(.>
I saw a 486/66 motherboard with CPU for $270 recently. The rediculous part is
memory will cost more than the motherboard. Simms run about $40 a megabyte.
Here is a message I posted to the gamdev forum a while back. I lean towards
mode 13, because it is easier to program and it is faster on new systems.
Mode X advantages:
1) Fast VRAM-VRAM blits.
This isn't a big advantage anymore with PCI and VLB cards. In fact,
I'm not even sure if it is faster on these types of cards.
2) Hardware scrolling.
There are very limited uses for hardware scrolling.
If you wanted to use hardware scrolling, you would have to combine it with
a dirty rectangle algorithm. This would be a pain and may end up slower,
than just rewdrawing the screen every time.
3) Square pixels.
4) Smooth animation with page flipping.
This is still a good reason to use mode X. Although there are ways to
get smooth animation in 13h.
5) Tripple buffering, so that you don't have to wait for verticle retrace.
Another good reason to use mode X. You can waist a lot of time waiting
for verticle retrace. It is possible to time the verticle retrace in mode
13h, but it is a lot harder to program than tripple buffering.
Mode X Disadvantages:
1) HARDER TO PROGRAM
2) Slower. This is debatable. It usually depends on the aplication.
Mode 13h advantages:
1) EASY TO PROGRAM
2) Faster. Again this is debatable.
3) Easier to port to Windows and OS/2.
Mode 13h disadvantages:
1) TEARING.
PCI and VLB video cards can blit a screen fast enough that you will
not get any tearing. You can also avoid tearing on slow cards by waiting
for the end of verticle retrace.
Jim,
Thanks. Good reply. I wonder if you can say a few more words about Triple
buffering. What do you mean by this? You mean writing a second page while
waiting for the vertical retrace so you don't have to just sit and wait for the
next one if it takes 2% too much time for a single screen draw? Would you do
this on another X-Page and then flip between 3 pages instead of 2?
Also, what do you mean by "tearing"? You mean that (sometimes moving)
horizontal line across the screen where you see one frame on top and the next
frame on the bottom?
If what I said about triple buffering is right, how do you know when to jump
out of your 2nd-page-draw and flip pages? Can you set up an interrupt that
calls the page flipper during retrace? If so, how?
And another thing – can't uou still do this in Mode 13?
Regards,
Fred Trafton
<You mean writing a second page while waiting for the vertical retrace so you
don't have to just sit and wait for the next one if it takes 2% too much time
for a single screen draw?>
Yes
<Would you do this on another X-Page and then flip between 3 pages instead
of 2?>
Right again.
<Also, what do you mean by "tearing"? You mean that (sometimes moving)
horizontal line across the screen where you see one frame on top and the next
frame on the bottom?>
Three for three.
<If what I said about triple buffering is right, how do you know when to jump
out of your 2nd-page-draw and flip pages? Can you set up an interrupt that
calls the page flipper during retrace? If so, how?>
You wait until you finish drawing to the page, and then flip pages. You
don't have to worry about when you flip pages, because the page flip will
not take effect until verticle retrace.
<And another thing – can't uou still do this in Mode 13?>
You can do this in mode 13h. As you know, in mode 13h you are using system
ram, that you copy to vram, instead of a true page flip. So you never know
if you are blitting the screen during retrace. To solve this problem you
have to sync the retrace with the timer so that you know approximately when
a retrace will happen.