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
 
... 110 posts hidden. Click here to view all posts....
 
2019-11-12 10:21
JackAsser

Registered: Jun 2002
Posts: 2014
@Krill: Nice!!!

So, now what about the shortest code to rotate a char? (or a reference to the message number if it's already stated here)
2019-11-12 12:46
Krill

Registered: Apr 2002
Posts: 2969
Jackasser: Shortest? Going fully academic, eh? =D

I guess it would be the naïve approach, in a nested loop (untested):
SOURCE = $02
DEST   = $0a

        ldy #7      ; 2
-       ldx #7      ; 2
-       lsr SOURCE,x; 2
        ror         ; 1
        dex         ; 1
        bpl -       ; 2
        sax DEST,y  ; 2
        dey         ; 1
        bpl --      ; 2
15 bytes.

But i'd rather have a faster than 280-ish cycles approach. =)
2019-11-12 13:58
Oswald

Registered: Apr 2002
Posts: 5086
sax for giggles ?
2019-11-12 14:46
Krill

Registered: Apr 2002
Posts: 2969
SAX because STA zp,Y does not exist.
2019-11-12 15:35
Oswald

Registered: Apr 2002
Posts: 5086
*clapping*
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
WVL/Xenon
Nordischsound/Hokuto..
Alakran_64
Guests online: 133
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 The Demo Coder  (9.6)
5 Edge of Disgrace  (9.6)
6 Mojo  (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 Musicians
1 Rob Hubbard  (9.7)
2 Jeroen Tel  (9.7)
3 Mutetus  (9.7)
4 Jammer  (9.6)
5 Linus  (9.6)

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