PetsciiPrint page

Last updated: 2017-05-09
Petscii is a tiny PHP library which converts text to PETSCII format. With this package, you can prepare your website to be fully compatible with web browsers available on Commodore 64 / 128 connected to internet via one of existing ethernet cartridges: 64NIC+The Final EthernetRR-Net or other. You can even surf the web using an emulator.

Petscii is available on Packagist so you can install it very easily via Composer. And of course, Petscii is used on Commocore website!

More details regarding compatibilities, features and how to install the library you will find in README:

We encourage you to read about limitations on Optimizing HTML for the Contiki Web Browser page and Help Support HyperLink 2.5.

Basic usage
Most important is to transliterate all text content, so that all special characters can be displayed properly on C64:

use Commocore\Petscii\Petscii;

$content = 'Olhão da Restauração';

$petscii = new Petscii();
$content = $petscii->render($content);

echo $content;

The result will be:

Olhao da Restauracao

You don't have to check if browser supports PETSCII. HTTP user agent is recognized automatically, and if a browser doesn't support PETSCII, text content will be displayed without any changes.

Make your site C64-friendly
If browser supports PETSCII, all JavaScript libraries, and all CSS files, etc. should be omitted to display page correctly, and much faster on C64. This simplified example should give you an idea:

if (!$petscii->isPetsciiBrowser()) {
    echo '<script src="/libs/jquery-2.1.4.min.js">';
    echo '<link rel="stylesheet" href="/css/style.min.css">';

Knock knock, who's there?
To log all user visits from PETSCII browsers, or display different content regarding particular browser, you can just check instance of class:

use Commocore\Petscii\Browser\Browseable;
use Commocore\Petscii\Browser\ContikiBrowser;

$browser = $petscii->getDetectedBrowser();
if ($browser instanceof PetsciiBrowseable) {
    // This browser supports PETSCII
    if ($browser instanceof ContikiBrowser) {
        // This is Contiki browser

List of recognized browsers are available in Commocore\Petscii\Browser\BrowserFactory class.

Downloading from webpage straight to C64
For example using Contiki web browser, you can download files straight to your floppy disk on Commodore 64 via WGET. Just create a link to file:

<a href="file.prg">Download me!</a>

Contiki and HyperLink supports submiting data from forms via GET method. It's not what you would expect, but it works. Simple form looks this way:

<form method="GET" action="/receive-data">
    <input type="text" name="my_field">
    <input type="submit" value="Submit">

One of ideas to test PETSCII view is to modify User-Agent header in your browser. There are few plugins which can be easily added to your favourite browser. The best of course, is to test the final result on a real thing. Or, on emulator.

To see characters available in a particular browser, you can create test page where you can generate list of all 256 characters this way:

echo $petscii->getTestPage();

Is it worth it?
Of course, Petscii cannot magically exchange your page without your effort. Probably you will consider changing a layout, implementing simpler menu, hide some parts, move search form to top of your page, add basic download link instead of button, exclude images, etc. And, is anyone using web browsers on C64 anymore? Probably not too many, but we think such ideas are worth spreading, and it's great fun! We also hope that these browsers will continue to be supported.

Copyright © 2011-2017 Vintage Carousel.
All rights reserved.