Jump to content
  • 0
Michael Parson

cc65: switch to uppercase/petscii

Question

When you write code using CC65, it defaults to switching you to mixed-case mode.

I'm looking for methods to switch back to uppercase/PETSCII mode.

On a C-64, I could use poke(53272,21), but the pokes are different on the X-16, and I haven't found this one documented yet.  If I was any good with machine language, I suppose I could poke (heh) around in the monitor and see if I could find that routine in the kernal, but I'm not.

So far, the best I've found is to:

#include <stdio.h>

int main(void) {
    printf("%c",142);
    printf("hello world\n");
    return 0;
}

However, I'd rather use the bits in conio.h, but conio seems to be using screen display codes rather than PETSCII values, that '142' with 'cprintf' gives me a reverse 'N'.

I've tried inline assembly (cribbed slightly from SlithyMatt's Hello cc65 tutorial):

#include <conio.h>

int main(void) {
    __asm__ ("lda $8E");
    __asm__ ("jsr $FFD2");
    cprintf("hello world\n");
    return 0;
}

But that didn't seem to do anything.

I suppose I could include both conio.h and stdio.h, but if it can be done w/o stdio.h, I'd save that much more RAM/code space.

Any other suggestions?

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

I can't test it right now but call to screen_set_charset function at $FF62 should do the trick. A can contain following values:

Value Description
0 use pointer in .X/.Y
1 ISO
2 PET upper/graph
3 PET upper/lower

 

Link to documentation:

https://github.com/commanderx16/x16-docs/blob/master/Commander X16 Programmer's Reference Guide.md#function-name-screen_set_charset

 

Share this post


Link to post
Share on other sites
  • 0

The printf version worked for me. cprintf will NOT work, because cprintf goes directly to VERA, rather than using the KERNAL, and so it will not recognize control characters. 

 

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, Greg King said:

Your __asm__ version will work, but you forgot one thing: a "#" in front of the "$8E".

That did it!  Thank you!

Share this post


Link to post
Share on other sites
  • 0

(I forgot about the Kernal wrapper functions.)

This is another way to do it:

#include <conio.h>

void main(void) {
    cbm_k_bsout(CH_FONT_UPPER);
    cprintf("hello world\n");
}

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use