Path: chuka.playstation.co.uk!news From: richard.cutting@virgin.net (Richard Cutting) Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Strange graphics happening Date: Wed, 10 Jun 1998 00:55:57 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 94 Message-ID: <357dd747.5343342@news.playstation.co.uk> References: <357d9ff8.785374@www.netyaroze-europe.com> NNTP-Posting-Host: p25-kestrel-gui.tch.virgin.net X-Newsreader: Forte Free Agent 1.11/32.235 On Tue, 09 Jun 1998 21:05:58 GMT, burrowinggerbil@hotmail.com (Barry Stuart Swan) wrote: >I have some massive problems with a game demo I am writing. >I wouldn't mind only it's for my dissertation at uni (ie my degree >depends on it) and it's due in in 2 days! > >It's a horizontally scrolling shoot em up game, and when I try >to have more than 20 enemies (that at this point simply consist of >32x32 sprites that use gssortsprite) they flicker and jump around >horribly. This is totally stupid, and I've tried varying every single >bit of code I have to no avail. >Also the rather unwanted side-effect of commenting out a function call >that is only 2 lines of code prevents the 2 following functions calls >to not work! > >I am totally panicking and would kill for any help! > >Because my university has failled to give me the required password and >web site URL that goes with the yaroze I am using, I have had to put >it on my brother's Middlesex account, and it can be found at: > >http://www.netyaroze-europe.com/~middex2/ftp/problem/hard.zip > >BTW since I am a beginner to C programming, I don't understand header >files properly, hence my program simply includes the other files (I >can afford to compile it like this since I have a relatively meaty >PC). What this means is that if you change any file, you'll have to >do MAKE CLEAN before MAKE, else it won't register changes in anything >other than main.c. Sorry, it's wrong and I know it, but no time to >change it now! > >Any help (incredibly) gratefully accepted! > >Barry Stuart Swan aka Gerbil Here's what I found. You use a variable currentBuffer to point to the currently active double buffer. The value of this variable gets set in the RenderWorld() function. The problem is that the variable is used before you use the RenderWorld() function for the first time. As it is uninitialised it will probably have a crap value in it, therefore when you use it the first time around in GsSortSprite() etc, you are bound to be crapping over some memory. What I did as a quick fix was; in the i_screen.c file I created a new function; void RenderStart(void) { currentBuffer = GsGetActiveBuff(); // determine which buffer is to be used GsClearOt(0, 0, &OTable_Header[currentBuffer]); // clear out OTable sorting info GsSetWorkBase((PACKET*)Packet_Memory[currentBuffer]); } I then removed the above three lines from the RenderWorld() function. I then changed the main() function so that RenderStart() is called before any updates.... void main() { Initialise(); while (GameRunning == 1) { Counter += 1; // Increment game counter RenderStart(); // ADDED UpdatePlayers(); // React to player input UpdateWorld(); // Update all the sprites RenderWorld(); // draw the screen }; ResetGraph(3); } The flickering sprites have gone on my system after I applied this. Hope this helps ! Good luck. Richard.