TRSE icon indicating copy to clipboard operation
TRSE copied to clipboard

C64 PrintString - Doesn't display all characters

Open phaze101 opened this issue 4 years ago • 3 comments

If you try to use printstring() to display some of the characters, it will not display them all.

Here is an example printstring("!@#$%^&*()-=_+[]:;<>?,./~",0,40);

Many of the character will not be displayed on the screen.

phaze101 avatar Dec 07 '20 23:12 phaze101

I believe it is connected to the string type, having a comma in a string causes problems. Possibly some other characters do also.

mystring: string = ("!@#$%^&*()-=_+[]:;<>?,./~");

AndyHOvine avatar Jan 05 '21 14:01 AndyHOvine

Comma has now been fixed up. The remaning I'll have to investigate - I'm simply using Qt's built-in "fromLatin" method to convert from a char to a numerical value

leuat avatar Jan 05 '21 15:01 leuat

I've also been running into this; I'm working on some C64 code that will end up printing out some mixed-case strings (e.g., Hello World! instead of HELLO WORLD! like all of the example code that comes with TRSE). Calling Poke(^$D018, 0, 23); to switch the C64 into uppercase/lowercase mode and then calling PrintString on a string variable containing the text Hello World! gives the output h%,,/ w/2,$!.

I thought it might just be a character layout issue, so I set about creating a custom character set, and moved the characters A-Z and a-z to where PrintString seemed to be pulling them from, which worked fine... but then as soon as I moved on to numbers (1234567890), those seemed to be pulled from all over the character map, including from the ranges that the letters A-z were being pulled from.

Also, when you define a string variable as cstring instead of string, the behaviour changes dramatically. A cstring variable containing the text Hello World! gives the output hello world! with PrintString when the C64 has been POKEd into uppercase/lowercase mode, which is a lot more intelligible than the string version, but it's missing the uppercase characters.

Here's a sample program you can mess around with if you like:

program Sample;

var
	hello : string = "Hello World!";
	const textLen : byte = 12;	// Change this to match the length of the above string
	textOffset : integer;

begin
	DefineScreen();
	ClearScreen(KEY_SPACE, #SCREEN_CHAR_LOC);
	ClearScreen(WHITE, #SCREEN_COL_LOC);
	Poke(^$D018, 0, 23);	// Put C64 into uppercase/lowercase mode

	textOffset := ((SCREEN_WIDTH - textLen) / 2) + ((SCREEN_HEIGHT / 2) * SCREEN_WIDTH);
	screenmemory := #SCREEN_CHAR_LOC + textOffset;
	PrintString (#hello, 0, textLen);

	Loop();
end.

vonmillhausen avatar Apr 18 '21 20:04 vonmillhausen