How to "rotate" a character..

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
Post Reply
User avatar
peacer
Flight Lieutenant
Posts: 348
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

How to "rotate" a character..

Post by peacer » Sat Mar 29, 2014 6:56 pm

For a simple animation, I plan to rotate a character over itself to the left.

$109D A0 07 LDY #$07 ..
$109F 18 CLC .
$10A0 B1 00 LDA ($00),Y ..
$10A2 0A ASL A .
$10A3 69 00 ADC #$00 i.
$10A5 91 00 STA ($00),Y ..
$10A7 C8 INY .
$10A8 D0 F5 BNE $109F ..
$10AA 60 RTS `


I plan to set DEEK(0) memory to set address of which character to rotate first. This should work if our character sets are 8x8 matrix but as oric character set is 6x8 pixels it does not work properly.

I think I have to check bit 7 after each ASL command but carry is set when bit 8 is on..

My brain stopped here. How can we achieve this simple action? Check bit 7 with operand AND with number "63" and then transfer it to carry? What could be the shortest code to do it?

User avatar
Dbug
Site Admin
Posts: 2268
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: How to "rotate" a character..

Post by Dbug » Sat Mar 29, 2014 8:41 pm

What about something like that:

Code: Select all

and #%00111111
cmp #64
rol
I've not checked if it worked, just what's coming to head :)

User avatar
peacer
Flight Lieutenant
Posts: 348
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: How to "rotate" a character..

Post by peacer » Sat Mar 29, 2014 8:50 pm

Comparing to 64 will alter N bit I think... After that, ROL would do anything with altered N bit?

User avatar
Dbug
Site Admin
Posts: 2268
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: How to "rotate" a character..

Post by Dbug » Sat Mar 29, 2014 9:09 pm

rol modifies N, but the only thing it uses (enters as low bit) is C.

User avatar
peacer
Flight Lieutenant
Posts: 348
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: How to "rotate" a character..

Post by peacer » Sat Mar 29, 2014 10:05 pm

So, lets say we have 36 in memory

and #%00111111 --> Still 36
cmp #64 --> Does nothing, N bit is zeroed.
rol --> result is 66

I think, I am expressing myself in wrong way.. Or I am misunderstanding what you mean..

I have a character matrix like this
100100
001001
010010
100100
100100
010010
001001
100100
Image


After rotation it should be ;
001001
010010
100100
001001
001001
100100
010010
001001
Image

User avatar
Chema
Game master
Posts: 1910
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: How to "rotate" a character..

Post by Chema » Sat Mar 29, 2014 10:18 pm

Cmp will also set the carry flag if the value is greater than or equal... Thus it should work.

http://www.6502.org/tutorials/6502opcodes.html#CMP

User avatar
peacer
Flight Lieutenant
Posts: 348
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: How to "rotate" a character..

Post by peacer » Sat Mar 29, 2014 10:26 pm

$109D LDY #$07 ..
$109F CLC
$10A0 LDA ($00),Y
$10A2 AND #$3F
$10A4 CMP #$40
$10A6 ROL A
$10A7 STA ($00),Y
$10A9 DEY
$10AA BNE $109F
$10AC RTS
Didn't work...

User avatar
Dbug
Site Admin
Posts: 2268
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: How to "rotate" a character..

Post by Dbug » Sun Mar 30, 2014 10:10 am

Except of course I should have written CMP #32, not 64.
Basically we want the state of the 6th bit in the carry before ROLling, not the state of the bit number 6 :)

User avatar
peacer
Flight Lieutenant
Posts: 348
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: How to "rotate" a character..

Post by peacer » Sun Mar 30, 2014 11:24 am

:) I overlooked that too.

I've learned antoher thing today.. Thanks so much.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest