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?
How to "rotate" a character..
Re: How to "rotate" a character..
What about something like that:
I've not checked if it worked, just what's coming to head ![Smile :)](./images/smilies/icon_smile.gif)
Code: Select all
and #%00111111
cmp #64
rol
![Smile :)](./images/smilies/icon_smile.gif)
Re: How to "rotate" a character..
Comparing to 64 will alter N bit I think... After that, ROL would do anything with altered N bit?
Re: How to "rotate" a character..
rol modifies N, but the only thing it uses (enters as low bit) is C.
Re: How to "rotate" a character..
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](http://puu.sh/7OtlH.pngg)
After rotation it should be ;
001001
010010
100100
001001
001001
100100
010010
001001
![Image](http://puu.sh/7OsUl.png)
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
After rotation it should be ;
001001
010010
100100
001001
001001
100100
010010
001001
![Image](http://puu.sh/7OsUl.png)
Re: How to "rotate" a character..
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
http://www.6502.org/tutorials/6502opcodes.html#CMP
Re: How to "rotate" a character..
Didn't work...$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
Re: How to "rotate" a character..
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![Smile :)](./images/smilies/icon_smile.gif)
Basically we want the state of the 6th bit in the carry before ROLling, not the state of the bit number 6
![Smile :)](./images/smilies/icon_smile.gif)
Re: How to "rotate" a character..
![Smile :)](./images/smilies/icon_smile.gif)
I've learned antoher thing today.. Thanks so much.