[cc65] ASCII, PETSCII, SCREEN and UNICODE (PetMe64 font)

From: <silverdr1wfmh.org.pl>
Date: 2011-12-19 19:42:35
While we are at some ASCII/PETSCII discussions, has anyone maybe heard of a decent conversion routines between the four (or at least PETSCII do UNICODE) having in mind the PetMe64 font?

I mean I have an algorithmic few lines of code that I can use for displaying things with PetMe64 font:

unsigned int unicodeBase = 0xe000;
unsigned int lowerUpperCharset = 0x0000;	// 0x100 if true
unsigned int reverseMode = 0x0000;		// 0x80 if true

[...]

if (currentChar < 32)
	[tempMutableString appendString:@"‽"];	// TODO: consider passing it further for processing
else if (currentChar < 0x60)
	[tempMutableString appendFormat:@"%C", unicodeBase + lowerUpperCharset + reverseMode + (currentChar & 0x3f)];
else if (currentChar < 0x80)
	[tempMutableString appendFormat:@"%C", unicodeBase + lowerUpperCharset + reverseMode + (currentChar & 0xdf)];
else {
	currentChar = currentChar & 0x7f;
	if (currentChar == 0x7e)	// Pi
		[tempMutableString appendFormat:@"%C", unicodeBase + lowerUpperCharset + reverseMode + (currentChar & 0x5e)];
	else 
		[tempMutableString appendFormat:@"%C", unicodeBase + lowerUpperCharset + reverseMode + (currentChar | 0x40)];
}

where unicodebase for copies of CBM characters is at $e000. This is relatively easy but of course it works then _only_ with PetMe fonts and disallow editing things using other fonts, which expect printable latin characters in ASCII range.

While I can imagine creating four tables for conversion _FROM_ PETSCII, doing the reverse (from UNICODE) doesn't seem to be feasible when I want to keep at least the latin characters understandable for non-PEtMe fonts.

Has anyone maybe tackled on this?

-- 
SD!

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Dec 19 19:44:46 2011

This archive was generated by hypermail 2.1.8 : 2011-12-19 19:44:50 CET