====== Support CBM/PETSCII Terminals ======
The Synchronet [[server:Terminal]] server can support Commodore PETSCII terminals.

Because the Commodore 64 only supported 40 column text modes, 40 column PETSCII is the most common mode:

{{:howto:40col_petscii_answer.png?600|Example 40 column PETSCII answer screen}}

However, a Commodore 128 could also support 80 column text mode, so 80 column PETSCII is also supported:

{{:howto:80col_petscii_answer.png?600|Example 80 column PETSCII answer screen}}

===== Detection =====
PETSCII cannot be automatically detected during connection, so specific TCP port most be assigned for 40/80-column PETSCII connections using any of the supported Terminal server protocols (i.e. Telnet, RLogin, or SSH), though typically only Telnet is used for PETSCII.

The 40 and 80-column PETSCII ports are specified by the ''Pet40Port'' and ''Pet80Port'' keys in the ''[bbs]'' section of the ''[[dir:ctrl]]/[[config:sbbs.ini]]'' file:

^ Key           ^ Default ^ Description ^
| ''Pet40Port'' | 64      | TCP Port used for 40-column PETSCII terminal connections |
| ''Pet80Port'' | 128     | TCP Port used for 80-column PETSCII terminal connections |

If any incoming TCP Terminal connections are accepted on either of these configured ports, then the terminal will be assumed to use PETSCII characters and terminal control sequences.

The initial terminal //width// (either 40 or 80 columns) will be determined based on which Terminal Server port answered the connection.

The initial terminal //height// will be assumed to be 24 rows.

If the Telnet protocol is used for the connection, it may be possible to detect different (e.g. larger) PETSCII terminal dimensions when the terminal dimensions are shared via Telnet option negotiation.

===== Listening =====

By default, the Synchronet Terminal server only listens on the standard TCP ports for the protocols supported (e.g. 23 for Telnet, 513 for RLogin, 22 for SSH). To add support for either or both PETSCII ports, you'll need to add one or both port numbers (following a colon) to one of the comma-separated address values for one of the ''Interface'' keys in the ''[bbs]'' section of the ''[[dir:ctrl]]/[[config:sbbs.ini]]'' file. Example:

  TelnetInterface = 0.0.0.0,0.0.0.0:64,0.0.0.0:128,::
  
===== Text =====

Characters are automatically converted (e.g. from ASCII/CP437) to the corresponding PETSCII equivalent. Some common characters (e.g. curly-brackets) are are not supported by PETSCII, so other characters (e.g. parenthesis) are used as replacements.

===== Colors =====

PETSCII terminals support most of the same colors as ANSI-BBS terminals, with a couple of important exceptions:

  * Colored (non-black) foreground text combined with a colored background is **not** supported: "Inverse text" is achieved using black foreground text on a colored background
  * Bright-background colors are supported

===== Cursor =====

Most of the ANSI-BBS cursor positioning sequences can be (and are) automatically translated for PETSCII terminals by the Synchronet Terminal server.

In JavaScript, most of the ''console'' methods for moving the cursor around the terminal work equally well for ANSI-BBS and PETSCII users.

===== Files =====

For files containing PETSCII characters, save those files with a ''.seq'' file extension.

For 40-column PETSCII files specifically, save those files with a ''.40col.seq'' file extension.

Likewise, an 80-column PETSCII file should be saved with a ''.80col.seq'' file extension.

===== Access =====

You can control (allow/deny) access to BBS features depending on whether the user is using a PETSCII terminal by using the [[access:requirements|ARS]] keyword: ''PETSCII''.

In JavaScript, the best way to check for terminal support is by using the ''console.term_supports()'' method. Example:

<code javascript>
  if (console.term_supports(USER_PETSCII)) {
    console.print("PETSCII support detected!"); 
  }
</code>

===== See Also =====
  * [[:howto:|howto index]]

{{tag>petscii}}
