| |
MRT Account closed
Registered: Sep 2005 Posts: 149 |
Dropping bits
Hmm, I've got a question for all you bitwise math cracks...
What is the best way (read: fastest way) to drop some bits of a group of bytes? And by dropping a bit I mean that the bit is deleted and not set to 0.
So for example:
Byte = 10100101
Dropping bit 2 from byte and reorder to the right, gives:
Byte = 01010001
I came up with a little routine which processes 4 bytes, dropping off bit 0 from every byte...
Example code follows:
-----------------------------------------------------------
B1: B2: B3: B4:
00110011 10100101 10010011 01010101
lsr B1 ;throw away 1 bit from B1
B1: B2: B3: B4:
00011001 10100101 10010011 01010101
lsr B1
ror B2 ;throw away 1 bit from B2
B1: B2: B3: B4:
00001100 11010010 10010011 01010101
lsr B1
ror B2
ror B3 ;throw away 1 bit from B3
B1: B2: B3: B4:
00000110 01101001 01001001 01010101
lsr B1
ror B2
ror B3
ror B4 ;throw away 1 bit from B4
B1: B2: B3: B4:
00000011 00110100 10100100 10101010
-----------------------------------------------------------
lsr B1 ;cc=5 (zp)
lsr B1 ;cc=5
ror B2 ;cc=5 (zp)
lsr B1 ;cc=5
ror B2 ;cc=5
ror B3 ;cc=5
lsr B1 ;cc=5
ror B2 ;cc=5
ror B3 ;cc=5
ror B4 ;cc=5
;-----
;cc=50
-----------------------------------------------------------
The routine only drops the first bit of the byte, not even an other bit (like the 2nd or 3rd) and this allready takes 50CC.
This can not bve the fastest way to do this... I'm missing something. So, does anyone know of a faster way to do this???
|
|
... 10 posts hidden. Click here to view all posts.... |
| |
MRT Account closed
Registered: Sep 2005 Posts: 149 |
???
ehr... huh???
What do you mean? and how does drawing a line help me with resizing a bitmap image in a fast manner? |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
MRT: this is done a hundred times less complicated in demos as you could ever imagine.
store your graphics into a charset. lets say your gfx is 32 characters wide. We need to store 4 versions of each char row. Each version is shifted 1 more pixel to the left.
now say we print out the chars normally.
x x x x
abcdabcdabcdabcd
each letter symbolizes a multicolor pixel, so one char is made up of abcd
now lets start the zoom:
x x x x x
abcdabcddabcdabcd
what happened ?
at the 3rd char we plotted a version thats shifted to the right 1 pixel, and so on afterwards.
hope you get the idea. as you have all versions of all chars shifted by 1-1 multi pixel, you can mix out zoomphases on a char basis very fast.
|
| |
Scout
Registered: Dec 2002 Posts: 1570 |
Quote: ???
ehr... huh???
What do you mean? and how does drawing a line help me with resizing a bitmap image in a fast manner?
Bresenham...that's the magic word!
---
-= Silicon Ltd. =-
http://forum.siliconlimited.com
Commodore 64 Scenemusic Podcast
http://8bitmayhem.blogspot.com/ |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
scout: no, thats metaballs |
Previous - 1 | 2 - Next |