Eng:Scratch and Commodore 64

🏴󠁧󠁢󠁥󠁮󠁧󠁿



The (short C64, colloquially with reference to the appearance of the first and a few subsequent versions also called "breadbox") is an 8-bit home computer with 64 KB RAM. Introduced in 1982 and equipped with outstanding sound and graphics capabilities for the time, the C64 reached high popularity as a gaming system, while at the same time it was also a programmable computer with built-in keyboard, which immediately after switching on started in programming mode. This motivated millions of users to try out programming.

Even decades after its introduction, the C64 continues to be popular. Currently a C64 compatible system called C64 Mini is available in hardware and there are still commercial games for the C64 developed. Because of similar system performance, the C64 could be thus also a way for Scratchers to move on as programmers or designers of small games.

Parallels between C64 and Scratch
C64 and Scratch were both extremely popular in their time with a similar audience: children and teenagers who are interested in computer programming and want to invent their own games. That's why there are many C64 retro fans today who see Scratch as a natural successor, with whom today's teenage generation can gain similar experiences as the teenagers did on their 64s in the 1980s.

The graphical programming possibilities of the two systems are similar despite the three decades difference: as with Scratch, there are movable sprites in the C64, which could be placed freely in front of the backdrop (and at the C64 by choice also behind it). Their costumes can be easily switched. The background can be painted on with a resolution of 320x200 pixels.

Regarding audio, the two systems differ greatly. While Scratch typically plays pre-recorded audio files and has only a rudimentary function for playing notes, the C64 offers a polyphonic synthesizer chip that allows the creation of professional sounds and music pieces. However, playback of recorded audio files is limited due to limitations in memory and processor speed.

The biggest difference comes with programming. While Scratch comes up with ready-to-use commands for placing or moving characters or playing sounds, the C64 comes with a rudimentary BASIC that requires POKE commands to manipulate graphics and sound directly manipulating a given location. Successor systems of the C64 had an extended BASIC, which offered the appropriate commands for sprites, sound and painting. Alternatively, you could upgrade the BASIC with Simons' Basic extension on C64 or use commands blocks in GameMaker.

Scratch Projects with References to C64
Scratch finds a number of related projects under the keyword "C64", which relate to the C64 in different ways:


 * General projects about C64 (info projects, fan-made commercials, ...):
 * Scratch64
 * C64 Fanmade Commercial
 * Commodore BASIC Versions
 * Commodore 64 Drawing


 * Well-known C64 games which were recreated in Scratch with similar aesthetics:
 * C64 Boulder Dash
 * Aztec Challenge
 * Buffalo Roundup
 * Way of the Exploding Fist


 * Projects that emulate sub-aspects of the C64, including the legendary SAM speech synthesizer:
 * Text to Speech - C64 SAM
 * C64 scroller
 * Commodore BASIC Interpreter
 * 10 PRINTCHR$(205.5+RND(1));:GOTO10

Scratch/C64 Web Player


A fundamental difference between C64 and Scratch is that the C64 exists as its own hardware, whereas Scratch runs as software in the web browser of a PC. However, so-called emulators have also made it possible to run C64 programs on a PC. Emulators for the C64 are around since more than 20 years. A well-known open source emulator is VICE - the Versatile Commodore Emulator, which can emulate not only the C64 but also other Commodore systems such as the PET, VC20, C16, C116, Plus / 4 or C128. An emulator is similar to the Scratch offline editor: the emulator must first be downloaded and installed, and then used to run or program C64 programs.

Meanwhile there exists also a comfortable webplayer for the C64: Rjanicek's Versatile Commodore Emulator for JavaScript. This html5 player plays C64 programs directly in the browser and is thus comparable to the upcoming Scratch 3.0 Web Player. This allows in particular the proliferation of new C64 games, since many users are reluctant to install software on their computer.

C64 as a Cultural Phenomenon
After its presentation in January 1982 by Commodore the C64 quickly raised to become the best-selling home computer of all times. Estimates of sales range between 12.5 million and 30 million pieces. There are about 10,000 commercial software titles that cover virtually all genres from games to business applications.

At the time of the C64 there were only a few people exchanging data over a network; The World Wide Web was invented much later in 1989. Apart from a few users who exchanged software and information via videotext systems such as BTX, networking between most C64 users took place through personal contact and exchanging software copies. However, most software titles were commercial and comparatively expensive which motivated so-called crackers to remove copy protection and re-distribute the software illegally. Therefore, the C64 was also known for its vivid software cracker scene.

There were a lot of magazines and books that printed code listing to be typed-in. Such listings were then often entered during several days of work and then saved (in the C64 usually a floppy disk or a cassette). The programs in the magazines often came from users who sent their self-made programs and games to the publisher. If a program was published in a journal, it was something similar like having a scratch project on the Frontpage by the Scratch Team. Unlike on Scratch one got paid for published programs with a honorarium equivalent to about 50 to 200 €. Individual competitions such as the GameMaker Design Contest even paid up to $ 5,000.

For subsequent models of the C64 such as the C128, C16, Plus/4, the software portfolio was much smaller, which severely impaired their success despite technical improvements. However, the Commodore 128 was fully compatible with the C64 and thus could benefit from the C64 software world.

While the C64 is no longer produced as a breadbox since 1994, there exist successor models such as the C64dtv which was published 2004. In 2018, British Retro Games Ltd. and Austrian Koch Media published the C64 Mini which is a C64 in the scale of 1:2. Unfortunately, the keyboard is just a dummy, so programming requires to connect a keyboard via USB.

Software for the C64 continues to be produced commercially and as homebrew projects. Today, most publised software are games or demos.

Programming the C64
The C64 comes with a preinstalled BASIC programming language, but the user is not bound to use only BASIC. Frequently used programming languages for the C64 are:

BASIC
The C64 comes with Commodore BASIC V2.0 preinstalled in ROM. Commodore BASIC is based on Microsoft BASIC which Commodore licensed from Microsoft with a one-time payment of $ 25,000. The offer from Bill Gates was originally a licensing fee of $ 3 per computer, which with millions of units would have been much more expensive for Commodore.

BASIC was at the same time also the interface to the operating system, thus actions such as saving a program, loading, displaying a floppy disk's contents or deleting a file were all initiated via BASIC commands. In BASIC V2.0 this often required cumbersome usage of the OPEN command:

The command "S:filename", for example, deleted a file. "S" stands for "scratch", in the sense of "scratching the program off the storage medium". In later BASIC versions there is even a command called SCRATCH.

Unfortunately, the included BASIC had no commands to access the graphics and sound hardware of the C64, so they had to be addressed directly via memory locations.

Access to the memory locations was done with PEEK (for reading) and POKE (for writing) commands. For example, to change the color of the backdrop to black you had to enter:

where the number 53281 stands for the memory location in which the VIC chip stores the screen background color and 0 selects the color black.

In later BASIC versions for other Commodore computers there were commands which were dedicated for setting colors, for example the COLOR command with the C128.



Simons' BASIC
The BASIC of the C64 is rudimentary, but allows to expanded with new commands. One year after the appearance of the C64, 16-year-old David Simons had programmed an extension for the C64 BASIC which was distributed by Commodore as a floppy disk version and as a cartridge. The so-called Simons' BASIC extended the Commodore BASIC by 114 additional commands which made the programming of sprites, high-resolution and multi-colored graphics as well as music and sound much easier. In addition, commands to support structured programming had been added.

David Simons contribution was very impressive, especially given his young age. In a similar way in Scratch it is also not uncommon that young programmers create a Scratch Modification by extending Scratch by several new blocks.





–

BASIC Compiler
The BASIC at C64 is like Scratch an interpreted language, which means that the commands are translated at runtime. This has advantages like faster startup and debugging capabilities in which a program can simply be stopped and resumed later. However, this comes at the expense of speed, which represents a major shortcoming, especially with the C64's processor clock running at only 1MHz.

BASIC compilers are programs that parse a BASIC program, translate the commands directly into machine language and then save the result. Such a translated program then runs much faster, but the translation process on a C64 usually takes several minutes. That is why the interpreter mode was often used for short tests and the final program was then translated with the compiler.

At Scratch, the Phosphorus and Sulfurous-Player use a similar technique to make the program faster, but thanks to faster hardware today, the translation process is much faster.

Assembler
Assembler is a language that specifies the machine code instructions one-to-one as so-called mnemonics. The assembler translates the mnemonics into the machine code which runs at much higher speed than programs coded in higher languages.

To change the background color, the assembler program would look like this:

The first command loads the value 0 into the accumulator, the second stores it in the VIC register for the background color. Compared to the command POKE53281,0 used above in the BASIC part, the assembly version is 1000 times faster!

Programming in Assembler is very tedious due to the small-scale commands, but allows the exact timing of the execution, which makes specific graphics and sound effects possible. BASIC and assembler programs can be mixed by calling a machine progam from BASIC with the SYS command and using the assembler command RTS (Return from Subroutine) to return to BASIC.

Cross-Development
In order to reduce the time when compiling a program, it is common today to edit the sourcecode on a PC and then use a cross-compiler to compile the program for the C64. The resulting machine language program is then transfered to a C64 or an emulator.

A notable compiler is CC65, which supports sourcecode in C or assembler or a combination of both in a project.

Garry Kitchen's GameMaker
Gary Kitchen's GameMaker was published Activision in 1985. The software greatly simplified the development of games. GameMaker was one of the first game development systems to include all the tools needed to create a game with the goal of enabling less experienced computer users to make games. In comparison, Scratch was created about 20 years later; even the precursors of Scratch such as Etoys and Squeak originated later in the 1990s.

Similar to Scratch, which features editors for sprites, sounds and code, GameMaker is divided into five tools, each consisting of a graphical interface controlled by the joystick:


 * The editor - for writing the code of the game
 * SpriteMaker - to define moving objects (Sprites)
 * SoundMaker - to create sound effects
 * SceneMaker - to draw background graphics
 * MusicMaker - for composing music pieces





In the programming editor, lines of text in a language based on BASIC were selected and configured with the joystick, similar to using Scratch Blocks with the mouse. Since all other tools could also be operated with the joystick, you could use the GameMaker leaning back without the need for touching the keyboard. Switching from the code editor to another editor, however, always required a reload from disk, which took about 30 seconds, so sometimes a lot of patience was required to operate the program.

A finished game can be exported with the GameMaker as a stand-alone program. At startup, the program then displays a welcome screen with an info about GameMaker. To date, the software site Gamebase64 lists 126 games that were created with GameMaker.

However, unlike Scratch, the GameMaker software did cost around $ 40 when it was first introduced. Adjusted for inflation this would equate $94 or €83 in today's money, an amount that kids could not easily afford.

–

Further Programming Languages Supported by the C64

 * Ada
 * APL
 * COBOL
 * COMAL
 * FORTH
 * FORTRAN
 * LISP
 * LOGO
 * M (MUMPS)
 * Pascal
 * PILOT

There are also a large number of non-standard programming languages, typically done as in-house developments only for the C64 or otherwise few platforms. Examples include the language PROMAL (PROgrammers Microapplication Language) or FCL (First Compiled Language) which was availble as type-in program with the English Commodore Magazine 44/1988.

To date, there are no implementations of graphical block-based languages like Scratch or Snap! on the C64.

Links

 * https://www.c64-wiki.com
 * Books on the topic of C64 and on how to learn programming freely accessible
 * Garry Kitchen's Game Maker (Product information)
 * Protovision develops and sells new games and hardware for the C64

Scratch und der Commodore 64