Path: chuka.playstation.co.uk!news From: "JohnT" Newsgroups: scee.yaroze.beginners Subject: Re: Plotting 2D Boxes in a 3D World (+ faster code hint!) Date: Fri, 15 May 1998 01:26:46 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 36 Message-ID: <6jg24u$f4o3@chuka.playstation.co.uk> References: <355a3dc2.2999054@news.playstation.co.uk> <355A67EA.137C@mdx.ac.uk> <355B0CD4.2A85@writeme.com> <355B86AD.3C0@manc.u-net.com> NNTP-Posting-Host: nettech.demon.co.uk X-Newsreader: Microsoft Outlook Express 4.72.3007.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3007.0 This is so true. I used to program assembly on my Atari STE and I found that for fast graphics I had to use shifting. I took those ideas over to C programming when I started on that. It's amazing how many programmers don't bother with this sort of thing just because of the power of the processors. If games (PC, PSX or whatever) where still programmed using those speed enhancing tips from assembly programmers working on slower machines the game would not need half as much processing power that they do these days. JohnT >Just one thing I'd like to say as I've been reminded by the array[x*y] >thing. This may be old news but here a little hint that assembly coders >will no-doubt know about. Say you have an array for a full screen: > >array[320*240]; > >As everyone knows you access a coordinate with the formula: x+y*320 >WRONG! It is much quicker to do x+y*256+y*64 (but using BITSHIFTS) to >avoid doing a (relatively slow) multiplication, like so: > >offset = x+(y<<8)+(y<<6); // for a screen 256+64=320 pixels wide > >Bit-shifts look scary to C newcomers (like when they first see the >code for the PadRead function) but THEY ARE THE WAY FORWARD FOLKS! >Use and Abuse 'em!! > >Jim > >PS I'll do some benchmarks on this soon for those who're interested.. >-- >----------------------------------------- >James Shaughnessy james@manc.u-net.com >http://www.netyaroze-europe.com/~shaughnj >-----------------------------------------