mass:werk / Blog

(Posts tagged “basic“.  All posts. RSS feed: Subscribe.)

The Commodore PET INPUT Bug-Feature

Adventures in MS BASIC (Commodore PET edition).

Well, another illustration

As it happens, I recently added a debugger to the PET 2001 emulator, with the expressed purpose of facilitating code reverse engineering. To celebrate this, we’ll risk a glimpse into a peculiar bug — or is it a feature? — of the BASIC flavor found on Commodore’s PET computers. Particularly, it’s about BASIC bailing out into a warm start, whenever an empty string is entered by just pressing RETURN on the INPUT prompt.

Continue reading…

The Case of the Missing 4th Commodore BASIC Variable (and the 5th Byte)

Another investigation into data types in Commodore BASIC.

Illustration: The case of the Missing 4th Commodore Variable…

We investigate the hair-raising case of the missing 4th variable type in Commodore BASIC…

Continue reading…

PET 2001 Emulator — V. 1.1

Proudly announcing version 1.1 of the PET 2001 online emulator.

Commodore PET 2001 Emulator V.1.1 Announcement
Yet another PET 2001 related title illustration.

Version 1.1 of the PET 2001 online emulator features a totally revamped mounting and loading mechanism for files. For users this means full access to disk directories and LOADing programs from inside BASIC. For all the nerdy details and some hilarious insights into Commodore IEEE file loading (like, “Where on Earth — uhm, in memory — is the BASIC scondary device address?”) follow the link:

Continue reading…

PET 2001 Emulator — V. 1.0

Proudly announcing version 1.0 of the PET 2001 online emulator.

Commodore PET 2001 Emulator V.1.0 Announcement
Yet another PET 2001 related title illustration.

Recently, I’ve been posting on Commodore BASIC and more specifically about the PET 2001 quite a bit. While not the sole reason, this was partly because I was adding a few features to the PET 2001 online emulator behind the scenes. I even endeavored into a major reorganization of some of the source code in order to facilitate this and future work. And, last but not least, there’s now even a suitable help file / documentation. — Reason enough to promote the emulator from its previous beta state to version 1.0!

Continue reading…

PETSCII Revealed

A closer look at the logic behind Commodore ASCII, AKA “PETSCII”, and the PET 2001.

PETSCII and the Commodore PET 2001
Investigations into a somewhat mysterious character code.

The flavor of ASCII used by the Commodore 8 bit computers, commonly known as PETSCII, is asking for a bit of an explanation. PETSCII is a peculiar beast, close to ASCII, but not quite, somewhat compatible, but not really, there are duplicate ranges of characters all over the place, and the special characters are lacking any recognizable order… — But look at all these these funny graphics characters!

In order to make sense of this and how the character set is organized, it may be helpful to have a closer look at it with a particular focus on the PET 2001. At least, this is the very machine, this character set originated on and for which it was designed for, with no idea yet that this may become the ancestor of a succesful line of home computers. Here, we may discover logic, in what must remain a puzzling enigma on the more popular and better known machines that followed, like the C64.

Continue reading…

Writing a PET 2001 Ten-Line Canyon Run Video Game

String exploits and a reasonably paced video game in just 10 lines of Commodore BASIC.

Writing a 10-line canõn run game on the PET 2001
Yee-haw! — A canyon to ride by just 10 lines of BASIC!

In continuation of and as a finale to our mini series on the internal representations of Commodore BASIC, we’ll now put some of our findings to use, especially some possible exploits of string variables.

What we’re going to do, is a classic canyon run game, where a single player rides/flies/drives/navigates a procedurally generated canyon down from the top, trying to progress as far and deeply into the winding depths as possible while avoiding the walls of the canyon. And we’re going to implement it in just 10 lines of BASIC, which puts some serious constraints on our solution. As do some of the intricacies of the PET 2001. Especially, we’ll have to avoid any direct access to the video memory (as in PEEKs and POKEs), meaning, we’ll do it all by print statements. So we’ll have to consult our bag of tricks — and come up with some exploits of the string mechanism.

Spoiler alert: It will be about fast partial strings and fast FIFO queues, while avoiding garbage collection.

Continue reading…

BASIC Variables & Strings — with Commodore

Investigations into the memory utilization of Commodore BASIC (PET 2001, VIC-20, C64)

Variables and Strings in Commodore BASIC
The astounding intricacies of Commodore BASIC variables.

In continuation of our last episode, we return to our investigations into Commodore BASIC memory representations. This time, it’s about variables, arrays, and, especially, strings.

Continue reading…

BASIC (Re)Numbering — with Commodore

How to thoroughly renumber Commodore BASIC programs (PET 2001, VIC-20, C64)

Renumbering Commodore BASIC
The curious wonders of Commodore BASIC renumbering.

Renumbering a is popular beginner’s sport for those who dare to venture into the mythical realms of intricacy, which the BASIC interpreter and its storage formats provide. Since it is also a useful utility, there are numerous programs for this, especially it’s a favorite example in the intructory sections of machine language guides. However, as always, there’s an easy way and a thorough one. And we’ll see soon, why this may be.

Continue reading…

Instant PET: Commodore BASIC as Data-URL

mass:werk proudly presents: Running BASIC on a virtual PET 2001 from URL-data.

Network URLs for a virtual PET

So you want to show your friends a little BASIC program or want to solve some problem with (retro) style? Despair no more, since help is near…

More specifically, just a click away, at www.masswerk.at/pet, where you find my enhanced version of Thomas Skibo’s in-browser PET 2001 emulation. What’s new is an additional mode, where the emulator loads (and runs) a program from data encoded in URL-parameters — as provided either in the query-string or in the URL-fragment (hash). And you may use this for immediate execution in direct mode, as well!

Continue reading…

A Curious Bug in the Commodore BASIC Tokenizer Routine

Investigations into a lesser known bug in Commodore BASIC abbreviations.

There is a well known, special feature of the BASIC implementation of Commodore 8-bit machines, namely abbreviated BASIC commands. While this is probably more a bug than a feature, this bug has a curious bug of its own. Reason enough to start an investigation.

VT100 Series CRT Typography
A slightly embarrassed Commodore PET.

Why are there these abbreviations, how do they work, and, what could possibly go wrong?

Continue reading…