Custom char issue in 6502
Moderator: Moderators
-
- Vic 20 Drifter
- Posts: 34
- Joined: Tue Oct 25, 2022 12:18 pm
- Website: https://winterfam.co.uk
- Location: Kent,uk
- Occupation: Author
Re: Custom char issue in 6502
Thanks Chysn, you're right that is really elegant, reusing the same pointer for both purposes.
-
- Vic 20 Drifter
- Posts: 34
- Joined: Tue Oct 25, 2022 12:18 pm
- Website: https://winterfam.co.uk
- Location: Kent,uk
- Occupation: Author
Re: Custom char issue in 6502
Worked a treat and my routine is working primo
Thanks for the help

-
- Vic 20 Drifter
- Posts: 34
- Joined: Tue Oct 25, 2022 12:18 pm
- Website: https://winterfam.co.uk
- Location: Kent,uk
- Occupation: Author
Re: Custom char issue in 6502
So is there a short cut using the same EOR method to adding / subtracting 72? I have a char set with 144 characters, first 72 are normal video, final 72 are reversed and I need code to switch between them.
I tried EOR and got the wrong answer. So I just wrote the longer version with adc/sbc.
24 EOR 97 = 121
So 24 EOR 121 = 97
But if I do 25 EOR 121 = 96 (and I need 98 as a result).
25 EOR 123 = 98
I'm probably being very dumb - but if I have to write code to calculate the EOR operand, I may as well just write the longer adc/sbc version? Or not?
Cheers
Martin
I tried EOR and got the wrong answer. So I just wrote the longer version with adc/sbc.
24 EOR 97 = 121
So 24 EOR 121 = 97
But if I do 25 EOR 121 = 96 (and I need 98 as a result).
25 EOR 123 = 98
I'm probably being very dumb - but if I have to write code to calculate the EOR operand, I may as well just write the longer adc/sbc version? Or not?
Cheers
Martin
- chysn
- Vic 20 Scientist
- Posts: 1204
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Custom char issue in 6502
TL;DR: No, not really.
You have to think about EOR, its operand, and the Accumulator, in binary terms. It's not anything like addition or subtraction. Each bit in the accumulator is set to 1 if and only if the corresponding operand bit's value is different than the one in the accumulator. So repeated operations with the same operand will cause the same bits to flip, resulting in moving back and forth between two values.
While I think it would be informative to see your actual code, it sounds like your best bet here is ADC/SBC.
-
- Vic 20 Drifter
- Posts: 34
- Joined: Tue Oct 25, 2022 12:18 pm
- Website: https://winterfam.co.uk
- Location: Kent,uk
- Occupation: Author
Re: Custom char issue in 6502
Thanks - it's working that way just fine, just trying to be efficient 

- Mike
- Herr VC
- Posts: 5130
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Custom char issue in 6502
Here's my take on it, the four instructions in $02A1..$02A6:

Upon the G 02A1 command and subsequent monitor G commands, $23 in the Accumulator toggles with $6B, and this also works as expected with all other values in the range $00..$8F.
Especially the scheme of "toggling upon toggle" is prone to failures. Miss one of those instances and they get out of sync. It is much more robust to toggle only at one place and then choose either the original range (when off) or 72 added to the range (when on).

Upon the G 02A1 command and subsequent monitor G commands, $23 in the Accumulator toggles with $6B, and this also works as expected with all other values in the range $00..$8F.
One suggestion: at this stage, your code should not try to be all too clever. Getting it working correctly is far more important!MartinC wrote:Thanks - it's working that way just fine, just trying to be efficient
Especially the scheme of "toggling upon toggle" is prone to failures. Miss one of those instances and they get out of sync. It is much more robust to toggle only at one place and then choose either the original range (when off) or 72 added to the range (when on).