prog8/examples/cx16/charsets.p8
Irmen de Jong ddb8346711 added txt.cls() as a shorter alternative to clear_screen().
cx16: added new character encodings, and routines in textio to enable the character sets for them.
cx16: added txt.chrout_lit() and txt.print_lit() to always print the literal characters and never as control codes
2024-04-07 19:32:44 +02:00

66 lines
2.0 KiB
Lua

%import textio
%zeropage basicsafe
main {
str buf = "?" * 20
sub start() {
txt.print("a demonstration of the various non-petscii character sets in the x16.")
wait()
latin()
wait()
cyrillic()
wait()
eastern()
wait()
ibmpc()
}
sub latin() {
txt.iso()
repeat 3 txt.nl()
write_screencodes(iso:"Latin: Le garçon n'a pas acheté d'œuf.")
txt.print(iso:"Latin: Le garçon n'a pas acheté d'œuf.")
}
sub cyrillic() {
txt.iso5()
repeat 3 txt.nl()
write_screencodes(iso5:"Cyrillic: 'Хозяин и Работник' написана Лев Толстой.")
txt.print(iso5:"Cyrillic: 'Хозяин и Работник' написана Лев Толстой.")
}
sub eastern() {
txt.iso16()
repeat 3 txt.nl()
write_screencodes(iso16:"Eastern European: zażółć gęślą jaźń")
txt.print(iso16:"Eastern European: zażółć gęślą jaźń")
}
sub ibmpc() {
txt.color2(5,0)
void cx16.screen_mode(1,false)
txt.cp437()
repeat 3 txt.nl()
write_screencodes(cp437:"≈ IBM Pc ≈ ÇüéâäàåçêëèïîìÄ ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ ☺☻♥♦♣♠•◘○◙♂♀♪♫☼ ►◄↕‼¶§▬↨↑↓→←∟↔▲▼")
; regular print() won't work because of control codes (<32) in this one.
txt.print_lit(cp437:"≈ IBM Pc ≈ ÇüéâäàåçêëèïîìÄ ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ ☺☻♥♦♣♠•◘○◙♂♀♪♫☼ ►◄↕‼¶§▬↨↑↓→←∟↔▲▼")
txt.nl()
}
sub wait() {
txt.print("\n\npress enter: ")
void txt.input_chars(buf)
}
sub write_screencodes(str message) {
ubyte column=0
repeat {
if message[column]==0
return
txt.setchr(column, 1, message[column])
column++
}
}
}