Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!markv From: markv@kuhub.cc.ukans.edu Newsgroups: comp.sys.amiga.programmer Subject: Re: best way to reverse a bitplane? Message-ID: <1991Apr29.155129.30171@kuhub.cc.ukans.edu> Date: 29 Apr 91 15:51:29 CDT References: <1991Apr29.101302.1@atmo2.atmo.arizona.edu> Organization: University of Kansas Academic Computing Services Lines: 31 In article <1991Apr29.101302.1@atmo2.atmo.arizona.edu>, leuthold@atmo2.atmo.arizona.edu writes: > What is the best way to reverse a bitplane? A brute force method would be > to reverse the bytes and then reverse the bits in each byte. The only way I > can think of to reverse the bits in each byte is to mask each bit off then > shift it to its new place and add it to the new byte. Is there a better way? Well, for a 68000, you have to do it bit by bit. However, your basic loop is going to have an AND, an OR, a LSR/LSL. With the 68000, you would get about 33% better speed with a BTST followed by a BSET. Note this assumes you optimize things for operand size, etc. In general you will gain a lot of speed by unrolling your loop for each bit, since you wont have to caclulate the Mask with for each bit. The 68020 and later have some bit range instructions that may help, but I dont have a reference handy. Also, I assume you mean reverse right/left, since a top bottom reverse can be done by just swapping bytes. Note the blitter doesn't help since all its DMA must progress in the same "direction". > Mike Leuthold > leuthold@atmo1.atmo.arizona.edu -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~