sblendorio
8/19/2018 - 1:07 PM

Commodore 64: conversion PETSCII -> Screen Code

Commodore 64: conversion PETSCII -> Screen Code

5 print chr$(147)
10 get a$:if a$="" then 10
20 a=asc(a$)
30 c=-1
40 if a>= 32 and a<=63  then c=a
50 if a>= 64 and a<=95  then c=a-64
60 if a>= 96 and a<=127 then c=a-32
70 if a>=160 and a<=191 then c=a-64
80 if a>=192 and a<=254 then c=a-128
90 if a=255 then c=a-161
100 if c<>-1 then print chr$(147);chr$(13);a$:poke 1024,c
110 if c=-1 then poke 53280,0:poke 53280,14
120 goto 10
PETSCII  | SCREEN  | FORMULA
---------+---------+------------
32..63   | 32..63  | PETSCII
64..95   | 0..31   | PETSCII-64
96..127  | 64..95  | PETSCII-32
160..191 | 96..127 | PETSCII-64
192..254 | 64..126 | PETSCII-128
255      | 94      | PETSCII-161