Path: chuka.playstation.co.uk!news From: Philip Gooch Newsgroups: scee.yaroze.beginners,scee.yaroze.programming.codewarrior,scee.yaroze.programming.2d_graphics Subject: Re: Still strugglin' with the basics: broken sprite code (long) Date: Fri, 17 Jul 1998 12:08:19 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 33 Message-ID: <35AF30A2.14DA9F66@easynet.co.uk> References: <35AC71D4.AA79EB4A@easynet.co.uk> <35AD10B6.153EE9C5@compuserve.com> <35AD2E8E.DEF2C169@nospam.easynet.co.uk> <35ADFF08.A310D245@easynet.co.uk> <35AE05C6.489D09F9@scee.sony.co.uk> NNTP-Posting-Host: 193.131.140.246 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (Win95; I) Xref: chuka.playstation.co.uk scee.yaroze.beginners:426 scee.yaroze.programming.codewarrior:309 scee.yaroze.programming.2d_graphics:450 James Russell wrote: > Philip Gooch wrote: > > > > Does the GsOT_TAG structure count as an enormous data structure? > > Generally, yes. > > > Is that why in this case it needed to be global (or static)? > > No. The reason it must be defined outside a function (or static) is because the GPU will be reading > it (so it can draw the screen) while the CPU is off Doing Other Things. If GsOT_TAG was defined > locally (and not static), its contents would be valid only for the 'life' of the function (the time > spent inside the function) it is contained in. > This means that if you create a valid GsOT_TAG structure (which is done by the system when you call > GsSortSprite() or GsSortObject4() ) and then set the GPU off reading it (using GsDrawOT), and then > exit your function to go and do other things, then the space used by the GsOT_TAG structure will be > reclaimed and probably wiped over, while the GPU is reading it! This is a very Bad Thing. So > defining this structure globally will solve the problem. If you want to keep it as a local variable, > defining it as 'static' will tell the compiler not to reclaim the space when the function exits. > This is very useful information. Thanks James. I think you've pinpointed what for me is the most difficult thing to master, which is how to handle the multitasking aspects of Yaroze programming. Cheers Phil