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


Forums > C64 Coding > Fast way to rotate a char?
2017-01-04 08:32
Rudi
Account closed

Registered: May 2010
Posts: 125
Fast way to rotate a char?

Im not talking about rol or ror, but swap bits so that they are rotated 90 degrees:

Example:

a char (and the bits can be random):
10110010 byte 1..
11010110 byte 2.. etc..
00111001
01010110
11011010
10110101
00110011
10110100
after "rotation" (rows and columns are swapped):
11001101
01011000
10100111
11111111
00101000
01010101
11011010
00100110
is it possible to use lookup tables for this or would that lookup table be too big?
or other lookuptable for getting and setting bits?

-Rudi
 
... 105 posts hidden. Click here to view all posts....
 
2017-01-05 10:19
CreaMD

Registered: Dec 2001
Posts: 3050
I wonder if this would significantly speed up my proportional routine and help me "posthumously" win the internal compo I had with Wotnau ;-)

So which one is the fastest? I need to rotate full line of bitmap 320 bytes char by char, +90 degrees each
2017-01-05 11:01
Dano

Registered: Jul 2004
Posts: 231
Haha, did my a proportial Routine for NewsPress back then the same way as CreaMD did. Switched to a standard one some time later as this was even faster. Guess i did the rotation the Oswald-way too back then.
2017-01-05 11:39
Oswald

Registered: Apr 2002
Posts: 5086
don think you can beat a bitshifter with this c2p, couple hundred cycles even with axis method, while bitshifter worst case is about 170 (lsr a ror zp * 8 lines * 3 times)
2017-01-05 12:52
Rudi
Account closed

Registered: May 2010
Posts: 125
Im trying to figure my head around this:
Since the rotation is just a bunch of bitswaps. For example swapping bit 0 and 7, bit 1 and 15, 2 and 23 etc.
00 01 02 03 04 05 06 07
08 09 10 11 12 13 14 15
etc..
56 57 58 59 60 61 62 63.
How would a swapbit-table look for this? The number of swaps are only 32. only 32 lda's and sta's? lets say ~8 cycles in total per swap: 8*32 = 256 cycles for all the swaps. but still I dont know if its possible to have a table for this..
Edit: hm, woops. i think perhaps 32 is wrong, since both locations need to be written to, so maybe two sta's instead of just one.
2017-01-05 13:11
Cruzer

Registered: Dec 2001
Posts: 1048
Oswald: Why 3 times and not 8?
2017-01-05 13:38
Oswald

Registered: Apr 2002
Posts: 5086
Quote: Oswald: Why 3 times and not 8?

coz you rotate in 2 buffers a,b:

a b
a b
a b

but if shifting is bigger than 3 you can just shift bits to opposite dir and then swap a,b (on screen). 3 is just a wild guess maybe 4 is the max, it was a long time ago.
2017-01-05 14:30
Rudi
Account closed

Registered: May 2010
Posts: 125
There is some interesting cyclic dynamic going on when looking at a bit-swapping method for 8x8 bits:

these figures shows that the outer layer is rotated 8 times first, then the next layer is rotated 6 times and so forth:
xxxxxxxx    ........    ........    ........
x......x    .xxxxxx.    ........    ........
x......x    .x....x.    ..xxxx..    ........
x......x    .x....x.    ..x..x..    ...xx...
x......x    .x....x.    ..x..x..    ...xx...
x......x    .x....x.    ..xxxx..    ........
x......x    .xxxxxx.    ........    ........
xxxxxxxx    ........    ........    ........
in this example one start with c0r0 and swap that with c7r0, then c1r0->c7r1, c2r0->c7r2 etc. so it goes around like a circle would. when that process is finished, the next inner layer does the same thing. until all four layers are done. and the result is a 90 deg rotation. its just one other way of looking at it. but still, a lookup-table for this? its difficult for me to see how. (im just giving out a few ideas for trying out other approach maybe).
2017-01-05 16:23
ChristopherJam

Registered: Aug 2004
Posts: 1408
Problem with bitshifter is it only deals with one bit at a time.

c2p exchanges four bitpairs in only 20-30 cycles. The expensive part is moving bits to matching positions within the two bytes they're being exchanged between...
2017-01-05 19:58
Digger

Registered: Mar 2005
Posts: 427
Nice read. But what fx do you have in mind Rudi?
2017-01-05 21:54
Rudi
Account closed

Registered: May 2010
Posts: 125
Quote: Nice read. But what fx do you have in mind Rudi?

My initial thinking was to make a sine-scroller, where the sinus-transform is done in chunky and then transformed using c2p. Of course the c2p-routine has to be fast enough for this. It would also bring out some new ideas for other vertical effects (that are first done with horisontal tricks, and then transformed using c2p). Unfortunately there seem to be no _really_ fast c2p routine.

Im still figuring out how that 4x4, 2x2 plus 1x1 rotator works. or that is; looking at every detail of the bit swaps.

Edit: hires-sinescroller.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 - 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
Mike
Alakran_64
Magic/Nah-Kolor
bugjam
Digger/Elysium
katon/Lepsi De
wil
zenda
REBEL 1/HF
gorans
Soya/Fairlight
chesser/Blazon
Guests online: 112
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 The Demo Coder  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Triad  (9.2)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

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