Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user eightbitswide ! (Registered 2024-12-24) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Dropping bits
2005-11-01 14:57
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....
 
2005-11-08 10:00
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?
2005-11-08 11:03
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.


2005-11-08 11:07
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/
2005-11-08 11:17
Oswald

Registered: Apr 2002
Posts: 5094
scout: no, thats metaballs
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Scan/House Designs
CreaMD/React
slimeysmine
Quetzal/Chrome
E$G/HF ⭐ 7
Guests online: 83
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 X-Mas Demo 2024  (9.5)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.052 sec.