Path: chuka.playstation.co.uk!scea!peter_alau@playstation.sony.com From: "dr Z" Newsgroups: scee.yaroze.beginners Subject: Re: Plotting 2D Boxes in a 3D World (+ faster code hint!) Date: 15 May 1998 04:04:48 GMT Organization: SCEA News Server Lines: 83 Message-ID: <01bca867$ef75bda0$1eb6e9cd@lausauvege> References: <355a3dc2.2999054@news.playstation.co.uk> <355A67EA.137C@mdx.ac.uk> <355B0CD4.2A85@writeme.com> <355B86AD.3C0@manc.u-net.com> <6jg24u$f4o3@chuka.playstation.co.uk> NNTP-Posting-Host: sie-182-30.sie.qc.ca X-Newsreader: Microsoft Internet News 4.70.1155 This is a little off topic but now on Pentium and on Power PC processors, using Y*320 instead of Y<<8 + Y<<6 is faster because of the cost of stalling the processor and the less cycles used by the multiplication instruction. And I agree that there is a lot of room for optimisation these days. Now, on a more related topic, could it be more faster and memory efficient to use GsLines instead of sprites or GsBOXFs. A line uses less packets in the WorkBase and the GPU doesn't have to do a look-up in VRAM. You could use a GsGLINE with the semi-transparency rate set to 1xback + 1xforward and a width of 2 to 4 to simulate the blur of a fast moving stars. something like: GsGLINE TheLine; TheLine.attribute = (1<<30)+(1<<28); TheLine.x0 = 0; TheLine.y0 = random(240); TheLine.x1 = 4; TheLine.y1 = TheLine.y0; TheLine.r0 = TheLine.g0 = TheLine.b0 = 0xFF; TheLine.r1 = TheLine.g1= TheLine.b1 = 0; To speed things up a little bit, you could put the GsLINE ( or other structure ) used many times in the Data-Cache of the CPU so it would be faster to copy it in the OT. Ex: // somewhere in the program #define MaxStars 500 typedef struct Star{ short X,Y; }Star; Star Stars[MaxStars]; //initialisation of the Star array register u_long i; for (i=0;iattribute = (1<<30)+(1<<28); TheLine->r0 = TheLine->g0 = TheLine->b0 = 0xFF; TheLine->r1 = TheLine->g1= TheLine->b1 = 0; // the drawing loop should look like this for (i=0;iX += 4) > MaxXRes ) { TheStar->X = -4; TheStar->Y = random(MaxYRes); } TheLine->x1 = (TheLine->x0 = TheStar->X) + 4; TheLine->y1 = TheLine->y0 = TheStar->Y; GsSortGLine(TheLine,ActiveOTPtr,StarsPri); } This way, only setting the X and Y attributes and passing the pointers to GsSortGLine should be faster in accessing half the main memory than before. Anyway, I'll take a look at your library sometime soon. Germain ( doctor Z ) Sauvé P.S. Excuse my crappy english.