Hi,
I'm using PrizmSDK and libfxcg found on github (https://github.com/Jonimoose/libfxcg), and found out that Chinese characters are shown as blank with the standard Print functions.
According to WikiPrizm, there might be flags or special system functions that enables Chinese output, but unfortunately it isn't descripted in detail.
So, has anyone figured out what should be done to print Chinese characters now? If not, is there any debuggers for fx-CG Manager Plus available so I can try to look into official Chinese applets (like Physium.g3a) and see what they do to display Chinese?
Deeply thanks.<3
xuhao394 wrote:
Hi,
I'm using PrizmSDK and libfxcg found on github (https://github.com/Jonimoose/libfxcg), and found out that Chinese characters are shown as blank with the standard Print functions.
According to WikiPrizm, there might be flags or special system functions that enables Chinese output, but unfortunately it isn't descripted in detail.
So, has anyone figured out what should be done to print Chinese characters now? If not, is there any debuggers for fx-CG Manager Plus available so I can try to look into official Chinese applets (like Physium.g3a) and see what they do to display Chinese?
Deeply thanks.<3


I've done some research and found how Chinese characters can be printed.

Normally, when one wants to print some English text, it can be done as follows:

Code:
PrintXY(1, 1, "  Hello!", 0, 0);

Output:
Hello!

A similar process can be followed for printing Chinese text:

Code:
PrintXY(1, 1, "\x3\xa8\xc4\xe3\xba\xc3!", 0, 0);

Output:
你好!

More generally, to start printing Chinese, one should begin the string with "\x3\xa8" instead of two spaces, and then add characters as follows:
1. Go to this GB18030 map and find your desired character (just use control + f).
2. Check the hex number in grey at the very left of that character's row. This is the first part of the character. For example, if this is C2, you should add "\xc2" to the end of your string.
3. Check the hex number in grey at the very top of that character's column. This is the second part of the character. For example, if this is 74, you should add "\x74" to the end of your string.
4. That's it! Add more characters using this process, or add english letters and punctuation as you would normally.

Here's an example:
You want to print "你叫什么名字?".
Follow the above process and you should end up with
你: \xc4\xe3
叫: \xbd\xd0
什: \xca\xb2
么: \xc3\xb4
名: \xc3\xfb
字: \xd7\xd6
? : ?

Thus, your string should be "\x3\xa8\xc4\xe3\xbd\xd0\xca\xb2\xc3\xb4\xc3\xfb\xd7\xd6?"
Put this into PrintXY and it should print
"你叫什么名字?"

Alternatively, if you have python on your device, you can use this to convert the Chinese to gb18030 using the string encode() method.
Here is an example:

Code:
"你叫什么名字?".encode("gb18030")

Output:
b'\xc4\xe3\xbd\xd0\xca\xb2\xc3\xb4\xc3\xfb\xd7\xd6?'

From this, copy the text from inside the quotes and add "\x3\xa8" to the start, as done previously. Put this into PrintXY and it will also print "你叫什么名字?".

Let me know if any of this doesn't make sense or needs further explanation.
dr-carlos wrote:
xuhao394 wrote:
Hi,
I'm using PrizmSDK and libfxcg found on github (https://github.com/Jonimoose/libfxcg), and found out that Chinese characters are shown as blank with the standard Print functions.
According to WikiPrizm, there might be flags or special system functions that enables Chinese output, but unfortunately it isn't descripted in detail.
So, has anyone figured out what should be done to print Chinese characters now? If not, is there any debuggers for fx-CG Manager Plus available so I can try to look into official Chinese applets (like Physium.g3a) and see what they do to display Chinese?
Deeply thanks.<3


I've done some research and found how Chinese characters can be printed.

Normally, when one wants to print some English text, it can be done as follows:

Code:
PrintXY(1, 1, "  Hello!", 0, 0);

Output:
Hello!

A similar process can be followed for printing Chinese text:

Code:
PrintXY(1, 1, "\x3\xa8\xc4\xe3\xba\xc3!", 0, 0);

Output:
你好!

More generally, to start printing Chinese, one should begin the string with "\x3\xa8" instead of two spaces, and then add characters as follows:
1. Go to this GB18030 map and find your desired character (just use control + f).
2. Check the hex number in grey at the very left of that character's row. This is the first part of the character. For example, if this is C2, you should add "\xc2" to the end of your string.
3. Check the hex number in grey at the very top of that character's column. This is the second part of the character. For example, if this is 74, you should add "\x74" to the end of your string.
4. That's it! Add more characters using this process, or add english letters and punctuation as you would normally.

Here's an example:
You want to print "你叫什么名字?".
Follow the above process and you should end up with
你: \xc4\xe3
叫: \xbd\xd0
什: \xca\xb2
么: \xc3\xb4
名: \xc3\xfb
字: \xd7\xd6
? : ?

Thus, your string should be "\x3\xa8\xc4\xe3\xbd\xd0\xca\xb2\xc3\xb4\xc3\xfb\xd7\xd6?"
Put this into PrintXY and it should print
"你叫什么名字?"

Alternatively, if you have python on your device, you can use this to convert the Chinese to gb18030 using the string encode() method.
Here is an example:

Code:
"你叫什么名字?".encode("gb18030")

Output:
b'\xc4\xe3\xbd\xd0\xca\xb2\xc3\xb4\xc3\xfb\xd7\xd6?'

From this, copy the text from inside the quotes and add "\x3\xa8" to the start, as done previously. Put this into PrintXY and it will also print "你叫什么名字?".

Let me know if any of this doesn't make sense or needs further explanation.


It works! Thank you so much. Very Happy
Now I wonder how to do the same thing with functions like PrintCXY and PrintMini, which treat the first two bytes as normal characters.
By the way, is there anything else I can refer to about fx-CG50 development besides WikiPrizm? Thanks.
I'm glad it worked for you!

Interesting question regarding PrintCXY and PrintMini. Given that Bdisp_WriteSystemMessage_WB seems to use PrintCXY under the hood, I would just try the same string with PrintCXY as you did with PrintXY and see if it works.

Try the same with PrintMini, though I'm not sure if the mini font supports Chinese characters.

Let me know how it goes.
dr-carlos wrote:
I'm glad it worked for you!

Interesting question regarding PrintCXY and PrintMini. Given that Bdisp_WriteSystemMessage_WB seems to use PrintCXY under the hood, I would just try the same string with PrintCXY as you did with PrintXY and see if it works.

Try the same with PrintMini, though I'm not sure if the mini font supports Chinese characters.

Let me know how it goes.


It doesn't work with PrintCXY Sad

Code:
\x03\xa8
is now treated as normal characters and Chinese is shown in blank again. I guess it has something to do with the unknown "P5", "P8" or "P9" arguments in the function
Code:
void PrintCXY(int x, int y, const char *cptr, int mode_flags, int P5, int color, int back_color, int P8, int P9)
, but I haven't figured it out yet.
xuhao394 wrote:
dr-carlos wrote:
I'm glad it worked for you!

Interesting question regarding PrintCXY and PrintMini. Given that Bdisp_WriteSystemMessage_WB seems to use PrintCXY under the hood, I would just try the same string with PrintCXY as you did with PrintXY and see if it works.

Try the same with PrintMini, though I'm not sure if the mini font supports Chinese characters.

Let me know how it goes.


It doesn't work with PrintCXY Sad

Code:
\x03\xa8
is now treated as normal characters and Chinese is shown in blank again. I guess it has something to do with the unknown "P5", "P8" or "P9" arguments in the function
Code:
void PrintCXY(int x, int y, const char *cptr, int mode_flags, int P5, int color, int back_color, int P8, int P9)
, but I haven't figured it out yet.


Interesting. I don't have my calculator on hand right now, but I'll have a look and let you know what I find.
xuhao394 wrote:
dr-carlos wrote:
I'm glad it worked for you!

Interesting question regarding PrintCXY and PrintMini. Given that Bdisp_WriteSystemMessage_WB seems to use PrintCXY under the hood, I would just try the same string with PrintCXY as you did with PrintXY and see if it works.

Try the same with PrintMini, though I'm not sure if the mini font supports Chinese characters.

Let me know how it goes.


It doesn't work with PrintCXY Sad

Code:
\x03\xa8
is now treated as normal characters and Chinese is shown in blank again. I guess it has something to do with the unknown "P5", "P8" or "P9" arguments in the function
Code:
void PrintCXY(int x, int y, const char *cptr, int mode_flags, int P5, int color, int back_color, int P8, int P9)
, but I haven't figured it out yet.


Okay, I've figured it out. When you call PrintXY("\x3\xa8 ... "), it runs the \x3\xa8 (0x3a8) through a function and sets it to Chinese text mode, then disables this afterwards.

PrintCXY and PrintMini don't do this. Thus, you will need to call ProcessPrintChars(0x3a8) before printing, and ProcessPrintChars(0) after printing. Unfortunately, this function is not included in libfxcg, and so you will have to add it via assembly.

An example program is as follows:

Code:

#include <fxcg/display.h>
#include <fxcg/keyboard.h>

int ProcessPrintChars();

__asm__(".text; .align 2; _ProcessPrintChars: mov.l sc_addr, r2; "
        "mov.l printchars_id, r0; jmp @r2; nop; "
        "printchars_id: .long 0x1300; "
        "sc_addr: .long 0x80020070");

void main(void) {
    ProcessPrintChars(0x3a8);

    // Print your Chinese here
    PrintCXY(10, 20, "\xc4\xe3\xba\xc3!", 0, 0xffffffff, COLOR_BLUE, COLOR_WHITE, 1, 0);

    ProcessPrintChars(0);

    int key;
    while (1)
        GetKey(&key);
}


Let me know if that doesn't work or doesn't make sense.
dr-carlos wrote:
xuhao394 wrote:
dr-carlos wrote:
I'm glad it worked for you!

Interesting question regarding PrintCXY and PrintMini. Given that Bdisp_WriteSystemMessage_WB seems to use PrintCXY under the hood, I would just try the same string with PrintCXY as you did with PrintXY and see if it works.

Try the same with PrintMini, though I'm not sure if the mini font supports Chinese characters.

Let me know how it goes.


It doesn't work with PrintCXY Sad

Code:
\x03\xa8
is now treated as normal characters and Chinese is shown in blank again. I guess it has something to do with the unknown "P5", "P8" or "P9" arguments in the function
Code:
void PrintCXY(int x, int y, const char *cptr, int mode_flags, int P5, int color, int back_color, int P8, int P9)
, but I haven't figured it out yet.


Okay, I've figured it out. When you call PrintXY("\x3\xa8 ... "), it runs the \x3\xa8 (0x3a8) through a function and sets it to Chinese text mode, then disables this afterwards.

PrintCXY and PrintMini don't do this. Thus, you will need to call ProcessPrintChars(0x3a8) before printing, and ProcessPrintChars(0) after printing. Unfortunately, this function is not included in libfxcg, and so you will have to add it via assembly.

An example program is as follows:

Code:

#include <fxcg/display.h>
#include <fxcg/keyboard.h>

int ProcessPrintChars();

__asm__(".text; .align 2; _ProcessPrintChars: mov.l sc_addr, r2; "
        "mov.l printchars_id, r0; jmp @r2; nop; "
        "printchars_id: .long 0x1300; "
        "sc_addr: .long 0x80020070");

void main(void) {
    ProcessPrintChars(0x3a8);

    // Print your Chinese here
    PrintCXY(10, 20, "\xc4\xe3\xba\xc3!", 0, 0xffffffff, COLOR_BLUE, COLOR_WHITE, 1, 0);

    ProcessPrintChars(0);

    int key;
    while (1)
        GetKey(&key);
}


Let me know if that doesn't work or doesn't make sense.


Yes it worked! That's so impressive.
Would you mind telling me what I should read if I want to dig deeper into CASIOWIN programming like you? Thank you.
xuhao394 wrote:
Yes it worked! That's so impressive.
Would you mind telling me what I should read if I want to dig deeper into CASIOWIN programming like you? Thank you.


All good.

In terms of digging deeper, here are some resources you might find helpful:
- Lephenixnoir's fxos. This is a disassembler specifically designed for the Casio fx and fx-CG series of calculators.

- Once you've installed the disassembler, you will need a copy of fxdoc (your 'fxos path'). The barebones version is available here, or you can download mine which has some extra syscalls and targets (but may be harder to set up).

- If you open fxos now with $FXOS_PATH set to your downloaded fxdoc, it should list some missing ROMs (.bin files). These can be downloaded from the 'Planet-Casio bible' in the common folder. Let me know if you're unsure which bin file (ROM) in fxdoc corresponds to which ROM on the bible, though it sohuld be pretty self-explanatory.

- If you're not familiar with assembly (especially for SuperH 4), I recommend checking out my guide, which is also on the Planet-Casio bible. Once you have a basic understanding of this, I recommend playing around with fxos and seeing what it can do.

- The whole Planet-Casio bible is a great resource which I thoroughly recommend digging through.

- If you are specifically interested in programming, I recommend Simon Lothar's folder, especially his list of fx-CG20 syscalls which contains most of the syscals we know today.

- I would also recommend my folder of the Planet-Casio bible, which contains a work-in-progress table of all 8040 syscalls for the Prizm OS 3.60, and many random addresses and functions which are interesting. It also contains equivalents (mostly) of 164 (and counting) syscalls/functions in the C language.

Feel free to make new threads about any questions or discoveries (or just here if they're related to this message or overall topic).
dr-carlos wrote:
xuhao394 wrote:
Yes it worked! That's so impressive.
Would you mind telling me what I should read if I want to dig deeper into CASIOWIN programming like you? Thank you.


All good.

In terms of digging deeper, here are some resources you might find helpful:
- Lephenixnoir's fxos. This is a disassembler specifically designed for the Casio fx and fx-CG series of calculators.

- Once you've installed the disassembler, you will need a copy of fxdoc (your 'fxos path'). The barebones version is available here, or you can download mine which has some extra syscalls and targets (but may be harder to set up).

- If you open fxos now with $FXOS_PATH set to your downloaded fxdoc, it should list some missing ROMs (.bin files). These can be downloaded from the 'Planet-Casio bible' in the common folder. Let me know if you're unsure which bin file (ROM) in fxdoc corresponds to which ROM on the bible, though it sohuld be pretty self-explanatory.

- If you're not familiar with assembly (especially for SuperH 4), I recommend checking out my guide, which is also on the Planet-Casio bible. Once you have a basic understanding of this, I recommend playing around with fxos and seeing what it can do.

- The whole Planet-Casio bible is a great resource which I thoroughly recommend digging through.

- If you are specifically interested in programming, I recommend Simon Lothar's folder, especially his list of fx-CG20 syscalls which contains most of the syscals we know today.

- I would also recommend my folder of the Planet-Casio bible, which contains a work-in-progress table of all 8040 syscalls for the Prizm OS 3.60, and many random addresses and functions which are interesting. It also contains equivalents (mostly) of 164 (and counting) syscalls/functions in the C language.

Feel free to make new threads about any questions or discoveries (or just here if they're related to this message or overall topic).


Thank you for your detailed advice! Very Happy I'm really curious about this calculator and its relatively rare SuperH architecture (compared to oft-seen m68k or ARM), and will try writing something else on it.
xuhao394 wrote:
Thank you for your detailed advice! Very Happy I'm really curious about this calculator and its relatively rare SuperH architecture (compared to oft-seen m68k or ARM), and will try writing something else on it.


Great! I'm glad you're interested!
dr-carlos has done an admirable job answering this question; I'm just going to note that I've added the relevant syscalls to libfxcg based on the documentation here, and updated WikiPrizm with the relevant information.
Tari wrote:
dr-carlos has done an admirable job answering this question; I'm just going to note that I've added the relevant syscalls to libfxcg based on the documentation here, and updated WikiPrizm with the relevant information.

Thanks for the help!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement