
Sign up to save your podcasts
Or


Sounds of the SID. Dan’s MEGA65 Digest for November 2022.
[Did you know: All issues of the Digest have an audio version! Search for “Dan’s MEGA65 Digest” in your favorite podcast app, or check out the audio player at the top of each issue. — Dan]
The Commodore 64’s Sound Interface Device (SID) chip was ahead of its time. While other personal computers were limited to simple beeps, the SID provided features comparable to professional sound synthesizers, with support for multiple kinds of sound waveforms, three-voice polyphony, and advanced filters and effects. Musician-programmers and game developers pushed the SID’s capabilities to the extreme, finding clever ways to drive the chip to produce multi-instrumental arrangements. To this day, artists continue to contribute to a vast legacy of SID-based music.
The MEGA65’s audio subsystem includes four SID chips, alongside more modern sound capabilities. In this Digest, we will scratch the surface of how the SID works, and how to produce sound and music with the SIDs from BASIC. We’ll also introduce a new music demo written for the MEGA65 that takes full advantage of all four SID chips. MEGA65 music is a big subject, and we’ll cover more music topics in future issues of the Digest.
But first, some news!
The new release bundle for the firmware and system software has completed testing and is now officially declared “stable.” The new batch of MEGA65 computers being delivered by the end of the year 2022 will have this release installed at the factory. Anyone who received their MEGA65 computer earlier this year is encouraged to upgrade.
Release bundles now have version numbers to make them easier to understand. The new release is known as release v0.95, and includes the MEGA65 core dated October 2022 (20221012.18,93d55f0) and MEGA65 ROM 920377. The previous release has been retroactively labeled v0.9.
I have updated the MEGA65 Welcome Guide to describe the upgrade procedure, and to welcome the new batch of owners. You can download the release v0.95 bundle from Filehost. Sign in with your account, make sure you have redeemed your owner code, then download the release package:
If you have any questions about upgrading, ask for help in the Discord!
The MEGA65 has a built-in Real-Time Clock (RTC) chip that keeps track of the date and time. If you haven’t yet, you’ll want to open your MEGA65 case and install a battery of type CR1220 on the main board. See the Welcome Guide for instructions with photos.
It was discovered earlier this year that a minority of MEGA65 computers contained faulty RTC chips, estimated to affect about 20% of computers. Faulty RTCs count the seconds too slowly or not at all. Starting with release v0.95 of the system software, the Freeze menu includes a diagnostic utility that knows how to test for a faulty RTC. (Open the Freeze menu and press the Help key to start it.)
The MegaInfo utility detecting a slow-ticking internal RTC.
If your MEGA65 has a slow or stopped clock, you can request a replacement part that connects to the main board. For instructions on how to run the diagnostic utility, and how to request a replacement unit, see this article on Filehost:
Thanks to the generosity of the MEGA65 community, we are able to offer this replacement part for the cost of shipping. Make sure your RTC fails the test with a fresh battery before requesting the part. We will send you email with the cost of shipping to your location after you submit a request, and you can cancel your request without remitting payment. Currently, shipping from the USA to Europe is $18 USD. We will try to find the cheapest shipping option to your location. We only accept PayPal at this time. [Update December 2022: Previously we covered shipping costs through donations. Donations have since been exhausted. Thanks to everyone who contributed!]
I am personally assembling these replacement parts in my basement! Many thanks to the MEGA65 team and community donors for making this fix possible.
The MEGA65 is not just a MEGA65. Thanks to its FPGA-based architecture, it can be reconfigured to behave like other computers. By far the most thorough transformation available today is the Commodore 64 core by MJoergen and sy2002, based on the MiSTer core. This core provides a PAL-mode C64 experience with a high degree of compatibility, and has been tested thoroughly with even the most intense games and demos. The “C64 for MEGA65” earns its place in slot 2 of everyone’s computers.
They’ve just announced a new release 4 of the C64 core, which adds RAM Expansion Unit emulation and writable D64 disk images. Many aspects of the core can be configured, especially display settings, and starting with this release you can save your settings to the SD card.
Download the C64 core from Filehost and install it from the core selection menu, similar to how you upgraded the MEGA65 firmware.
The simplest way for a computer to make sound is to send ones and zeroes to a speaker. A “one” pushes the diaphragm of the speaker all the way out; a “zero” pulls it all the way in. If the computer sends alternating ones and zeroes fast enough, we perceive the pressure wave generated by the diaphragm as sound.
The faster the computer alternates the ones and zeroes, the higher the pitch of the sound we perceive. The slower the alternations, the lower the pitch. We can describe the pitch of the sound in terms of the frequency of the repetitions, expressed as the number of repetitions per second, or Hertz (Hz). A frequency of 880 Hz is higher in pitch than a frequency of 660 Hz.
The more forcefully the computer pushes the diaphragm of the speaker, the louder the sound. This is known as the amplitude of the wave, or the volume of the sound. The computers sending ones and zeros to a speaker are beeping as loud as they can: the difference between the “one” and the “zero” is as much as it can push the speaker. If you’re lucky, such a computer has a volume knob connected that reduces the amplitude of the signal electronically before it reaches the speaker.
With only ones and zeroes at its disposal, it might seem like this simple computer can only make one kind of sound at different pitches, or no sound at all. In fact, it can change the nature of the sound in one other way. When it sends a “one” for a small fraction of a second then sends a “zero” for that same amount of time, and repeats this pattern at a given frequency, the computer generates a special kind of pulse wave known as a “square wave.” The computer can also differ how long it holds the “one” relative to the “zero,” known as the pulse width. The pulse width affects the timbre of the sound, a musical term referring to the nature of the tone independent of its frequency or amplitude.
It’s worth pausing here to admire what creative coders have done with these simple pulse waveforms. By rapidly adjusting the frequency and width of these pulses in complex patterns, computers can generate music that sounds, at least to a generous observer, like a band of instruments playing a tune.
Pulses are a crude digital way to make noise. By the time of personal computers, musicians had already spent decades developing sophisticated analog sound synthesis techniques. To break free of pulse waves, computers needed analog devices that they could control digitally, entire chips dedicated to sound and music.
Commodore’s solution was the MOS 6581 Sound Interface Device, now known the world over as simply “the SID chip.” The SID brought sound synthesis features previously found only in professional musical instruments to home computing, and became a defining characteristic of Commodore computers. For later models of the C128 and C64C, Commodore used an improved version with the part number 8580 with minor differences from the 6581. Audiophiles are divided as to which version sounds best. SID designer Bob Yannes went on to found the Ensoniq synthesizer company with an expanded version of the SID in its instruments.
The SID can generate four distinct types of sound wave: pulse waves of multiple pulse widths, triangle waves, sawtooth waves, and a randomized “noise” waveform. A single SID chip has three independent signal generators, capable of three simultaneous “voices” with separate wave and volume controls that can be combined for effects or used as separate instruments. (The 8580 can even merge the waveform types, but this is seldom used.)
The SID can trigger tones programmed with a volume pattern known as an “envelope” that can reproduce behaviors of musical instruments and other sound sources, such as a bowed violin or a plucked guitar. The signal generators can be synchronized and modulated with each other, and the combined output can be filtered by frequency.
The SID made the Commodore 64 popular with musicians, and composers produced a long legacy of SID music for games and demos. Third-party hardware such as the SID Symphony cartridge gave the Commodore a second SID chip, and you can find many six-voice dual-SID compositions in the archives. Today, hobbyist-made devices to add a second SID chip to a C64 are widely available. The vintage SID chips themselves are getting increasingly difficult to find, though hobbyists have recreated them as FPGA-based devices that slot in to vintage and retro hardware.
The MEGA65’s audio subsystem includes four SIDs as part of its FPGA architecture, for a total of twelve independent voices. The MEGA65 produces stereo audio, and by default places SIDs 1 and 2 panned slightly to the right, and SIDs 3 and 4 slightly to the left. You can adjust the mix yourself from the Freeze menu: hold Restore for a second then release, then press the A key to select the audio mixer utility.
The MEGA65 also has separate hardware for playing 16-bit digitized audio samples, and room to add a Yamaha OPL FM synthesizer in a future firmware update. Altogether, MEGA65 audio represents multiple generations of microcomputer sound technology.
MEGA65 BASIC makes it easy to include sound and music in your programs with simple commands. BASIC reserves two SID chips (six voices) for sound effects and the other two SIDs (the other six voices) for music, so effects and music never compete for resources.
All sound occurs simultaneously with the action of your program: the commands return control immediately, so your program can continue to drive animations and game logic while the music plays. This powerful feature is unlike any other BASIC, which, if they have sound commands at all, typically wait for the sound to finish playing before proceeding to the next command.
While these commands do not provide access to all of the features of the SID chips, they’re a quick and easy way to add sound and music to your BASIC programs.
The SOUND command plays a single sound effect. When you provide the voice number (1-6), a frequency (in Hz), and a duration, it plays a square wave:
The duration is in a unit called a “jiffy.” The length of a jiffy depends on the MEGA65’s video mode: in PAL mode, it’s 1/50th of a second, and in NTSC mode it’s 1/60th of a second. (We’ll discuss this oddity a bit later.) So a duration of 90 in NTSC video mode would sound the tone for one and a half seconds.
The SOUND command can apply fun frequency sweeping effects, good for sirens, whoops, and rumbles. The sweep is described by three parameters. The first parameter is the direction of the sweep: 0 for up, 1 for down, and 2 to wobble up and down. Next is a second frequency lower than the first, defining a range that the sound will sweep between. The last sweep parameter is a duration of each repeat of the sweep. Larger numbers produce faster sweeps and more repetitions over the duration of the sound effect.
Experiment with these numbers to see what sounds you get.
The command accepts additional parameters to select a different waveform or set the pulse width. If you want to use one or both of these parameters without a frequency sweep, provide empty values (just commas) for the sweep parameters.
For the waveform parameter, select 0 for a triangle wave, 1 for a sawtooth wave, 2 for a pulse wave, and 3 for noise. If you select the pulse wave (the default), you can set a pulse width in the range 0-4095.
Here’s a non-sweeping triangle wave:
This produces low noise:
A noise waveform with frequency sweeping might sound like an airplane engine sputtering:
Try the pulse waveform with different pulse widths to see how it affects the sound of a pulse wave:
While you could generate musical melodies using a series of SOUND commands, this isn’t convenient. Instead, BASIC 65 has a featureful music system, and it’s based entirely on strings—strings of text, that is.
The PLAY command accepts up to six string parameters, one for each voice reserved for music. Each string describes a sequence of notes and directives to be performed by the voice. Sequences for separate voices are performed simultaneously, so you can generate harmonies and rhythms.
This command plays a simple melody using a piano-like sound:
These are the notes C, E, and G, played in sequence with a single voice. To play them simultaneously as a chord, we give one note to each voice in separate strings:
The directives and notes in a PLAY string are evaluated in order from left to right. A directive affects all subsequent notes played by the voice, until another directive changes the effect. For example, the O directive sets the octave with a number in the range 0-6:
PLAY will ignore spaces in the string, so you can organize the symbols for clarity.
Each note is a letter in the diatonic C major scale: A, B, C, D, E, F, or G. The letter can be preceded by modifiers: the # symbol to make it sharp or the $ symbol to make it flat. For example, $B is B-flat. A note can also be the letter R to specify a rest.
A note is a quarter note by default. You can precede it with a letter to set its length: W for whole note, H for half note, Q for quarter note, I for eighth note, and S for sixteenth note. Any of these followed by a dot (.) extends the duration by half: a dotted quarter note is the same duration as three eighth notes. For example, S#F is an F-sharp sixteenth note.
The note duration persists for the voice like a directive, so you only need to specify it once in a run of notes with similar durations.
You can adjust the tempo for the entire song using the TEMPO command. Its sole parameter is a number in the range 1-255, where larger values are faster. You can think of this value in terms of beats per minute divided by ten: TEMPO 12 sets the tempo at 120 bpm. (The User’s Guide defines this value as the denominator in a fraction of seconds for a whole note, which breaks my brain.)
So far we’ve been playing a piano-like instrument. This is defined by a combination of the SID waveform type and an “envelope” that describes the volume curve for each note. The envelope consists of four segments, during which the volume increases (the attack), abates (the decay), holds (the sustain), then fades out (the release). This is what differentiates instrumental notes from the solid tones we produced with the SOUND command.
BASIC 65 starts with 10 default instrument envelopes, numbered from 0 to 9: piano, accordion, calliope, drum, flute, guitar, harpsichord, organ, trumpet, and xylophone. To change the instrument being used, issue the T directive followed by the number.
Some of the instruments are more convincing than others, and may require some experimentation to fit your song.
You can overwrite any of the ten instrument slots with your own definition. See the ENVELOPE command in the User’s Guide for more information.
The L directive tells the PLAY command to loop to the beginning of the string. This is great for background music that needs to play indefinitely. Remember to loop all voices for a piece of music in the same place—or loop them in different places for interesting effects! For instance, you can have a short loop for drums and a long loop for verses and choruses.
Issuing a new PLAY command with a new sequence for a voice that’s currently playing will stop the current sequence and start the new one. If you want a voice to continue playing while you issue a new sequence to a different voice, leave an empty parameter.
If you want your program to wait until a PLAY sequence has completed, use the `RPLAY(n)`` function to test whether a voice is currently sounding. It takes the voice number as a parameter, and returns 1 if that voice is making sound, or 0 otherwise.
To silence all voices, issue the PLAY command without parameters. You will probably use this often when debugging games with background music, as the music will keep playing after the program halts with an error.
When you first turned on your MEGA65, it loaded the demo disk menu with some jaunty background music. This menu is a BASIC program, and the music is produced by the PLAY command. Run the menu, exit to BASIC, then LIST the program to find the PLAY statements.
The User’s Guide describes a few more features of the PLAY command not covered here. The PLAY command can actuate the ring modulation feature of the SID, an effect that involves combining multiple voices in a complex way, so you’ll want to read more about that. PLAY can also enable and disable the filter on the SID; filter parameters can be set with the FILTER command.
Remember that PLAY sequences are BASIC strings. This means you can assemble and manipulate these strings as values before passing them as arguments to PLAY. This also means they are constrained by the BASIC limit of 255 characters per string. If you run out of string, you might consider breaking your composition into parts, and using RPLAY() to wait for each part to finish before PLAYing the next part.
The best way to learn is to experiment! Remember that you can always reset the computer and try again.
Earlier, we said the SOUND command measures duration differently depending on which video mode your MEGA65 is in: PAL or NTSC. Why would the video mode have anything to do with playing sound?
Programs that play music are sensitive to timing. They need to execute code with strict regularity to make sure the music keeps up with the beat. Commodore games and demos typically tie their playback loops to another part of the architecture that keeps strict time: the video chip. Using raster interrupts, they set up their code to trigger each time the video chip refreshes the screen. The screen refreshes an exact number of times per second, so this is a good way to advance to the next step in a music composition with strict regularity. It’s like turning the cylinder of a music box at a steady pace.
There’s just one problem with tying playback to the video refresh rate: the PAL and NTSC video standards used different rates! Commodore made different versions of their computers for the analog video standards in the countries where they were sold, PAL in Europe and NTSC in the United States and Japan. (In countries that used a third standard called SECAM, Commodore sold PAL computers with video adapters.) PAL refreshed the screen at 50 Hz, and NTSC refreshed at 60 Hz. In many cases, games and demos written for one video standard played too slowly, too quickly, or not at all on a computer built for the other standard. It’s possible to write a program that works similarly for both, but this requires additional effort, and few people had both kinds of computers to test with.
The MEGA65 outputs a modern digital video signal that supports multiple refresh rates. For compatibility with older software, the MEGA65 continues to honor PAL and NTSC as separate video modes, including their raster timings. Many modern digital displays will honor both modes, but some of us have older displays that get confused by one or the other. You may or may not remember setting your default video mode when you turned on your MEGA65 for the first time.
You can check which mode you’re in, and change it, in the Freeze menu: hold Restore for a second then release, then locate the Video setting (PAL50 or NTSC60). Press the V key to switch between them. If a game or demo isn’t running correctly for you and your display supports both modes, try switching modes and running the program again.
Can the display you use with your MEGA65 support both PAL and NTSC video modes, or just one or the other? Developers want to know!
MEGA65 musician and demo coder deathy has set up a one-question survey that asks which video modes your set-up supports. Please take a moment to answer it. It’ll be a big help to MEGA65 game and demo developers!
[Update: Some readers have reported that SurveyMonkey is failing to show the survey correctly in some European countries. You might be able to copy-paste the URL after visiting it: https://www.surveymonkey.com/r/BBFR5WG ]
Syntax 2022, the 16th annual demo party in Melbourne, Australia, took place this month, and the MEGA65 was there! deathy and MEGA65 contributor Gurce, both members of the BAS demo group, produced “Xanadu,” a two-part tribute to the late Olivia Newton-John.
Part one is written in assembly language and features an arrangement of the Newton-John classic using all four SID chips. Part two offers another take, this time rendered entirely in BASIC with the PLAY command.
Download the D81 disk image and run it on your MEGA65 today!
There’s plenty more to say about music on the MEGA65, but it’ll have to wait for future issues. Until next time, thanks for listening!
— Dan
MEGA65 Adventures! Dan’s MEGA65 Digest for October 2022.
Personal computers in the early 1980s ignited the home video gaming industry with their ability to display animated color graphics. Even so, the games with the best images were the ones with no graphics at all. Text adventure games told tales of fantasy, mystery, and suspense with you as the protagonist, rendering entire worlds using only the written word and your imagination.
The effectiveness of the medium and the limited hardware requirements have made text games the longest living and most widely supported form. Archivists, hobbyists, and game authors have reverse engineered and ported vintage text games to modern computers, and evolved the form into the modern day. Thanks to members of our community who have continued that work, you can play a vast legacy of interactive fiction—everything from classic games to new releases—on your MEGA65.
In Hibernated 1 by Stefan Vogt, you play Olivia Lund, a space-faring explorer whose long voyage to Alpha Centauri is interrupted by a mysterious alien vessel. With your artificial intelligence companion Io, you must board the vessel and learn its secrets to break free of its tractor beam.
To play a text adventure game, you describe the actions of your character in abbreviated English commands. The story proceeds with each action, so you can take your time to read descriptions for clues and work out solutions to puzzles. In Hibernated 1, you navigate around spaceships (yours and theirs) with commands like starboard, port, fore, and aft. You can also examine objects to investigate your surroundings.
Some objects can be taken, carried, and used at various points in the story. Others are fixed in place, and you must remember where they are and come back to them when needed. When playing text adventures, it is critical to take notes and draw maps in a paper notebook so you don’t lose your way.
Stefan originally released Hibernated 1 for the Commodore 64 and several other systems in 2018. In 2021, he rewrote the game with a revised story and puzzles, and published the “Director’s Cut” for a whopping twenty-eight (28) microcomputer platforms. You can even play it on a modern computer. Hibernated 1: Director’s Cut is available for the MEGA65, with an 80-column text display and the ability to save your progress to disk.
You can download Hibernated 1 from 8bitgames.itch.io. The download is free of charge; donations to the developer are welcome.
For an authentic vintage software experience, you can purchase a physical boxed edition of Hibernated 1 for the MEGA65 from publisher poly.play. The physical edition comes on a 3-1/2" floppy disk that you can use with your MEGA65’s floppy drive, in a gorgeous display box designed to resemble the games we used to buy in computer stores. And just like Infocom games back in the day, the box is packed with extras.
The physical edition of Hibernated 1: Director’s Cut qualifies as the first commercial title for the MEGA65. If boxed software appeals to you, you might also be interested in the second qualifying title, Showdown by Badger Punch Games, a two-player action game for the MEGA65 available in a display box from poly.play and as a download from badgerpunch.itch.io.
The most famous name in text adventures is Infocom, an American software company founded in 1979. Their most famous game was Zork, a treasure hunting adventure that begins in a boarded up cottage in the woods. Infocom published 36 original text adventures over ten years, including several Zork sequels and an adaptation of The Hitchhiker’s Guide to the Galaxy by Douglas Adams.
Key to Infocom’s early success was the ability to publish versions of their games for multiple microcomputer platforms simultaneously. All games were written in a custom programming language that ran on a common engine known as the Z-machine (Z for Zork). Infocom made versions of the Z-machine for every major microcomputer from the Apple II to the Amiga. This effectively erased the difference between each type of computer as far as the game’s Z-machine code was concerned: the story could be written once, compiled to Z-code, then interpreted by each platform’s Z-machine to play the game. When a new kind of computer came to market, Infocom simply built a new Z-machine for it, then re-released their entire catalog.
The longevity of this strategy continues to this day, over 40 years later. After Infocom ceased operations, hobbyists reverse engineered and documented the Z-machine standard. It’s a fun coding exercise to build your own Z-machine that can run Infocom story files, and implementations exist for nearly every modern computer. This is how Stefan released Hibernated 1: Director’s Cut for twenty-eight computers simultaneously: it’s a game written for Z-machines.
The Z-machine is a popular target for modern authors thanks to its ubiquity. The annual Interactive Fiction Competition gets new entries in this format every year, and you can find plenty more via the Interactive Fiction Database. Be sure to look for game files with names with endings such as .z3, .z5 or .z8. (There are several other formats used for interactive fiction, including Glulx, TADS, Twine, and more.)
Ozmoo is a Z-machine player by Johan Berntsson and Fredrik Ramsberg for the MEGA65, Commodore 64, Commodore 128, and Commodore Plus/4. It’s a modern take on the idea, capable of taking advantage of each machine’s capabilities to their fullest extent, especially when extra memory is available. Ozmoo can run pretty much any game written for the Z-machine, including nearly all Infocom games and most modern Z-machine games.
Infocom experimented with sound effects and still graphics for a few of their games. Ozmoo supports the ones with sound effects, but not the ones with graphics (“v6” files).
The best way to get Ozmoo games for your MEGA65 is with Ozmoo Online, a web-based utility that can convert any compatible Z-machine game file into a playable D81 disk image. Ozmoo is free and open source, and you can learn more about it from the Ozmoo Github repository.
Fredrik, known as fredrikr on the Discord, has done a ton of great work to make interactive fiction available to the MEGA65 community. For starters, Ozmoo Online has every classic Infocom game available for download. Simply select one of the provided story files from the menu instead of uploading one.
Be sure to select MEGA65 as the platform, and “81” as the build mode. I also recommend enabling the scrollback buffer, a handy feature of Ozmoo that works well with the MEGA65’s “AtticRAM” extended memory.
Fredrik has packaged the two Infocom games with sound files as a separate MEGA65 download. You can find it on Filehost:
If you’re playing Infocom games, you’ll also want the original game manuals. You can download PDF scans of these from infodoc.plover.net. Some of the manuals contain information required to finish the games.
The interactive fiction community has been developing new Z-machine games for decades. Fredrik has bundled a selection of the best of these, using Ozmoo for the MEGA65. These are also on Filehost:
Need more? Try these text adventures written by MEGA65 owners, including two by Fredrik himself:
Infocom used their own custom language called “ZIL” to write their games. Contemporary authors use a family of languages called Inform, specifically Inform 6 and Inform 7. A newer language called Dialog is also worth a look, especially when writing games for microcomputers.
Inform 6 is a programming language for writing Infocom-style adventure games for the Z-machine. Typically, you use it with the Inform 6 standard library, which implements a wide range of useful object properties (doors, keys, containers, food) and player verbs (open, unlock, put in, eat). The Inform 6 compiler is a command-line tool that takes an Inform 6 source file and produces a Z-machine game file.
Here’s a tiny excerpt of how a bit of the Docking Bay in Hibernated 1 might be implemented. (This is not the actual code. Among many things, I’ve omitted code that replaces “north” and “south” with shipboard directions “fore” and “aft.”)
Even though Inform 6 is intended to build to the Z-machine format, its standard library was written with modern computers in mind, and tends to produce game files too large to run on vintage microcomputers. Ozmoo co-author Johan Berntsson produced PunyInform, a replacement for the Inform 6 standard library optimized for low memory computers like the Commodore 64. You use PunyInform with the Inform 6 compiler.
macOS and Linux users can download the Inform 6 source bundle with everything you need, including the Inform 6 compiler, standard library, and PunyInform. The Interactive Fiction Archive also has pre-built versions of Inform 6 for many platforms, library add-ons, and plenty of example code. I recommend using Visual Studio Code to write Inform 6 games: there are extensions available that allow you to compile and play your game directly in the editor.
The definitive book about the Inform 6 language is The Inform Designer’s Manual by Inform’s creator Graham Nelson. It’s exceptionally well written and includes general information about interactive fiction and game design, as well as a tour of the language and its library. I consider it a classic text, and recommend it to anyone with even a casual interest in the subject. Read it online, or buy it in hardcover or paperback.
Inform 7 is a newer language and authoring system for narrative game writing. It’s a radical departure from Inform 6, using a logical programming paradigm and a natural language syntax, so source code reads like English prose. Inform 7 also includes a friendly authoring application where you can write an Inform 7 game, test it, read high quality documentation, and even develop automated tests that put your game through its paces.
Here’s how that Docking Bay example would be written in Inform 7 (again, not the actual code):
Inform 7 is designed to be accessible to authors without a computer programming background, but it doesn’t skimp on computational power or expressiveness. Some programmers prefer Inform 6 because it looks more like a programming language. Most new language innovation is happening with Inform 7.
The only reason I didn’t give Inform 7 top billing in this section is that games made with Inform 7 tend to run slowly on microcomputers. The MEGA65 version of Ozmoo can handle simple Inform 7 games with the “Inform 7 XL Stack” option enabled in Ozmoo Online, but they tend to be too slow to play.
For making Z-machine games for the MEGA65, stick with Inform 6. If you also want your game to run on smaller machines like the Commodore 64, use PunyInform instead of the Inform standard library.
Dialog is another modern take on writing interactive fiction by Linus Åkesson. It borrows ideas from Inform 7 and the Prolog programming language, with an emphasis on minimalism, clarity, and performance. Dialog brings some of the best language design ideas to games that can be played on vintage microcomputers with Z-machine players. Like Inform, Dialog includes a rich standard library that makes starting new stories easy.
Here’s my novice attempt at describing the Docking Bay in Dialog:
Dialog includes a command-line compiler and a handy interactive debugger. The software bundle includes pre-built tools for Windows and Linux, and it’s easy to build them from source on macOS. Linus also has his own alternative to the Z-machine, which he calls the Å-machine, optimized for converting Dialog games to playable web pages and Commodore 64 disk images.
I’ve always been interested in how computers can be used to tell stories. One of my favorite books as a kid was Creating Adventure Games on Your Computer by Tim Hartnell (1983, Ballantine Books). In fewer than 200 pages, Hartnell covers game design, BASIC coding techniques, and several fully playable adventure games that you can type in, play, and modify.
I love the title of the kid’s book Creating a Database Adventure Game by Steve Rodgers and Marcus Milton (1985, Aladdin Books). It’s a genuine insight that adventure games are like explorable databases: tables of values that describe the state of the world, and long strings of text that become the game’s narrative based on the player’s actions.
Write Your Own Adventure Programs by Jenny Tyler and Les Howarth (1983, Usborne Publishing) is another, with excellent visualizations of how BASIC programs are structured. Both of these books use a grid structure to represent the game world, with each cell a location with potential exits in the four cardinal directions (north, east, south, west).
Compute!’s Guide to Adventure Games by Gary McGath (1984, Compute! Books) only dedicates a few chapters at the end to authorship, but it includes useful advice on structured programming and a short type-in. Most of the book is a catalog of the state of adventure games of the era, summarizing their stories and reviewing their features. Infocom gets its own chapter.
Of all the books on BASIC that came out of the 1980s, the ones about adventure games were some of the most informative and inspirational. They described how to organize large programs, how to design and implement data structures beyond simple variables, and how to build a game engine as much as a game. And they showed how evocative text games can be, even with no graphics, simple command parsers, and short text descriptions. You can read these vintage BASIC books and others on Archive.org.
I was going to write up a bunch of tips for coding adventure games in MEGA65 BASIC for this Digest, but we’re running a little long. Instead, here’s a brief example of a technique for representing a world map that’s common to most vintage BASIC books on the subject: the travel table.
Let’s say our game takes place on the Polaris 7, Olivia’s ship from Hibernated 1. At the beginning of the game, Olivia can access five rooms: the Hibernation Chamber, the Lower Corridor, the Private Area, the Docking Bay, and the Airlock. Olivia can navigate these rooms by traveling fore, aft, starboard, or port, according to the entrances and exits to each room.
For this example, we’ll go with the simplest possible command parser. We’ll use an INPUT statement to accept the command, and compare the value against the four directional commands. If a command is recognized, it is converted into a number from 0 to 3 in the C variable, and processing continues on line 380. Otherwise it is rejected with a message, and control loops back to the INPUT statement.
The travel table is a two-dimensional array, with one row for each room, and one column for each movement direction. The value of a cell represents the exit for that room in that direction. If the value is a room number, that is the destination of the exit. If the value is 0, then there is no exit in that direction. We reserve room #0 for this purpose, so room numbering starts at #1. For example, the Docking Bay has an exit fore to the Lower Corridor (room #2). Fore is direction 0, so the Docking Bay’s zero-th column in the travel table is 2.
We initialize the TT(room, direction) array by reading the map data from DATA statements. For convenience, we put the room names on the same lines in the DATA statements and read them into the RO$(room) array.
Olivia begins the game in the Hibernation Chamber, room 1. The PL variable stores her location. At the top of the game loop, we tell the player where they are, and which directions from the current room have exits—that is, are non-zero in the travel table.
Now we can finish processing the command. With a valid direction command in the C variable, we can determine whether there is an exit from the player’s current location in that direction by consulting the travel table. If not, we inform the player. Otherwise, we move the player to that location, then return to the top of the game loop.
That’s a complete albeit not very interesting game. It might be more interesting if there’s an object that the player can find to open the security door fore of the Lower Corridor. We might update the room description routine at the top of the game loop to announce whether the object is in the player’s current location. It might also describe the security door when the player is in the Lower Corridor, and whether it is open or closed. A new command could allow the player to pick up the object, when appropriate. When the player opens the security door, the game logic would update the travel table to allow passage between the Lower Corridor and what lies beyond.
This isn’t MEGA65 specific but I can’t close this out without recommending 50 Years of Text Games by Aaron Reed, a historical deep dive on the genre and its many unusual twisty passages. Well researched and compellingly written, Reed originally published this as a serial newsletter, then crowdfunded a book version. The project raised over $640,000.
The Kickstarter has ended, but there is a limited number of extra print copies available for pre-order. If you’re still reading this Digest, you’ll love Aaron’s book.
The MEGA65 might be my favorite text adventure gaming platform. With the distraction-free 80-column display and quality mechanical keyboard, I can shut off the Internet and immerse myself in an interactive story. And the large amount of memory, fast disk access, and ability to store a giant library on an SD card mean I can play modern text games without the limitations of other microcomptuers.
I hope you give at least a few of these games a try, and maybe write one of your own. Happy adventuring!
— Dan
MEGA65: The Next Batch! Dan’s MEGA65 Digest for September 2022.
First off, thank you all so much for the outpouring of support for this Digest idea. I didn’t expect to see so many of you subscribe to a newsletter sight unseen. I really hope it’ll be an enjoyable use of your attention.
And boy did we time this right, because we get to discuss big news in the first issue!
MEGA’s assembly and distribution partner Trenz Electronic has parts in hand for the next batch of 400 computers, and is scheduled to assemble and deliver them by the end of the 2022 calendar year. Soon there will be 800 MEGA65s in the hands of new owners, not counting the 100 Dev Kits.
All batch #2 machines will ship with updated factory-installed firmware and system software, including fixes and improvements made since batch #1 shipped back in May. Batch #2 will include the printed User’s Guide from the first print run. If you receive a batch #2 machine, you’ll want to download the most recent PDF as a supplement. I’ll try to keep the Welcome Guide up to date as well.
Trenz is planning these fulfillment batches based on the availability of parts, especially the Xilinx FPGA chips. The MEGA65 team has done a great job mitigating risk in the supply chain, with unusual pieces like the injection molded cases and floppy disk drives well stocked. (We were all surprised when the first batch was delayed due to a shortage of cardboard, of all things.) We can all look forward to continued fulfillment of pre-orders through next year.
The MEGA65 community made a huge push to test the factory-installed firmware and system software for batch #1. We’re doing it again for the batch #2 release candidate—and you can help!
The closer you can get your MEGA65 to the final configuration, the better for testing. If you own a MEGA65, a Dev Kit, or a Nexys FPGA board, jump in the #release-test forum on the Discord. Check out the release candidate verification home page with links to downloads and instructions for testing and reporting bugs. You can install the latest core in slot 1 of the core management utility, and prepare a new internal SD card with the latest system software and bundled disk images.
If you’re one of the lucky ones to have both a batch #1 MEGA65 and a JTAG programming interface, you can install the candidate core in the special “slot 0,” which is how batch #2 machines will be configured. Overwriting slot 0 requires opening your case to flip a tiny switch, as well as running some fancy commands. We need slot 0 testers, so if this sounds like you, please give it a try. See the wiki page for instructions.
If you don’t yet have a MEGA65, you can still help test the ROM using the Xemu emulator. You’ll need to use the C65 ROM diff files along with a copy of the original Commodore 65 ROM version 910828 (which you can find online or on the C64 Forever CD-ROM) to produce the mega65.rom file.
Thanks to everyone who can help out!
The core team and contributors have been improving the MEGA65 firmware and system software (including the MEGA65 version of the Commodore 65 ROM code) continuously since batch #1 shipped. So what’s considered the “latest” version, and should you upgrade?
There are two major release packages for the system software: the stable release package, and the experimental release package.
The stable release package contains the most recent set of software that has been through a testing phase, which today is the factory-installed set from batch #1. It includes MEGA65 core version 20220109.11,1586ad4 and the MEGA65 ROM version 920287. When we’ve completed verification of the batch #2 software set, that set will become the new stable release. You can download this from the MEGA65 R3 Release Package page on Filehost. (You’ll need a Filehost account registered with your owner code to access it, because it contains the licensed ROM.) Stable releases have their own version number to represent the entire set of software, with the current release known as version 0.9.
The experimental release package is the bleeding edge, built regularly from the latest changes committed to the source repo. As of this writing, the experimental package download contains core version 20220717.12-develo-3253c5d. Contributors do their best to keep everything in working order when they submit changes. For additional assurance that changes maintain backwards compatibility, they are held in this “experimental” state while we test them and put them through their paces. You can download the experimental release core and system software from the Experimental Release MEGA65 R3 page on Filehost.
Unlike the stable package, the experimental release package does not contain the ROM. As of now, the latest ROM is 920377, and is available from the C65/MEGA65 Kernal ROM page on Filehost.
The batch #2 verification build has its own download page and may be slightly newer than the experimental release during the test phase.
Which release you choose to install on your own MEGA65 is a matter of taste. Everyone is encouraged to install the latest stable release. For batch #1 owners, this just means that we’ll throw an upgrade party when batch #2 is finalized. If you don’t want to hassle with frequent upgrades of experimental releases, and the occasional downgrade when issues are discovered, stick with the stable release and watch for announcements. If you’d like to preview new features, get the latest bug fixes, and help test new contributions, consider installing the latest experimental release. I’ve had a good time keeping the latest experimental release on my MEGA65 all year, though I’ve also been paying close attention to bug reports.
One of the coolest things about the MEGA65 is that it’s easy to switch between multiple versions of these components. You can have multiple cores in flash memory, you can have multiple ROMs on the SD card, and you can easily switch between them when you boot the machine. This is not quite true for the auxiliary system software in those .m65 files on the SD card. If you find yourself switching between stable releases, you might want more than one SD card prepared with the appropriate files. The differences in the files between experimental releases tend to be minor enough to just use one SD card.
As of right now, my personal recommendation is for batch #1 owners to proceed with upgrading to the experimental or batch #2 verification release set. Since batch #1 shipped, newer releases have fixed noticeable bugs and improved the overall quality of life for MEGA65 owners. You’ll also be helping with the verification effort by upgrading now. When the batch #2 testing phase completes, that’ll be a good time to install the new stable release as your default core (in slot 1) and default ROM (with filename mega65.rom).
As anyone who has done software release management professionally can tell you, release verification is an expensive process. We’re gradually building out automated testing solutions to reduce the time between stable releases, though this is challenging when custom hardware is involved. I’m grateful to everyone who tests experimental releases. You make continuous improvement possible!
For instructions on how to upgrade your MEGA65’s firmware and system software, see the User’s Guide included with the machine, as well as the Welcome Guide.
ZeHa of Dr. Wuro Industries (known as ZeHa on the forums, drwuro on Discord) is producing Megazine, a printed zine of type-in BASIC programs for the MEGA65, and is calling for submissions. If you’ve always wanted to see one of your programs featured in magazines like Compute!’s Gazette, now is your big chance!
Megazine is looking for BASIC programs with a focus on fun, such as games, animations, or demos. Keep it short, and keep it readable enough for beginner programmers to understand. (I remember doing a type-in as a kid and encountering the word FORK in the program and wondering what it did. It took me a moment to realize it was just a FOR statement and a variable named K, with the space removed.) Also please only submit unreleased programs.
When the zine was originally announced, the submission deadline was set at September 30. This will probably be extended, though a new date has not yet been determined as of this writing. Check out the original forum announcement for submission details and updates.
One of the easiest ways to get started with programming games on the MEGA65 is with character graphics. Your BASIC program plots colored letters and symbols on the screen, checks whether the joystick or fire button is pushed, and decides on new positions for player, enemy, and environment objects. Do that in a loop and you’ve got a game.
Just like with the Commodore 64, you can replace the glyphs used for each letter or symbol with your own custom designs. And starting with ROM version 920347, MEGA65 BASIC makes this super easy!
The CHARDEF command takes the character screen code whose glyph you want to replace, and eight numbers that describe the new 8x8 pixel image, one number for each row. Try this at the READY. prompt:
If you get a SYNTAX ERROR, double-check that you’re using the latest version of the ROM. (ROM 920347 came after the batch #1 v0.9 release.)
Now type the “at” symbol (@) a few times.
The first 0 is the screen code for the “at” symbol. Screen codes 1 through 26 are the letters A through Z. See this table for all the screen codes. CHARDEF supports the first 256 screen codes in the uppercase PETSCII mode. (This will be updated to support all 512 codes, uppercase and lowercase PETSCII, in an upcoming release of the ROM.)
Each of the numbers following the screen code describes a row of the character glyph.
MEGA65 BASIC’s built-in support for hexadecimal notation comes in really handy here, because each hexadecimal digit describes exactly four pixels.
Many of the games I wrote as a kid featured this classic “brick wall” glyph. Look at the diagram below. What hexadecimal numbers describe this pattern? What CHARDEF command would change the letter A to appear as a brick wall?
To restore the glyphs back to the MEGA65 PETSCII font, use the FONT command, with the letter C as an argument:
There’s also a FONT A, which replaces some lowercase glyphs with ASCII punctuation not available in PETSCII, and FONT B which resembles a DOS-like font. Try them! (Remember you can toggle between uppercase and lowercase modes with Mega+Shift.)
With CHARDEF in your BASIC programs, you’re well on your way to making some fun games. Be sure to submit yours to Megazine!
That’ll do it for this month. Best of luck to all the testers, and congrats to everyone about to receive a new MEGA65!
Keeping Up With the MEGA65, Dan’s MEGA65 Digest for August 2022.
The party was already in full swing when I got my MEGA65 back in March of 2022. I got mine as part of the first shipment of production units, the ones with the sweet injection molded cases, but 100 others already had the acrylic-encased Dev Kit beta units from the previous year. Many more were eagerly running the MEGA65 core on Nexys FPGA boards or testing the waters with the Xemu emulator. By the time batch #1 shipped, it included multiple disk images packed with demonstrations and games from an already thriving community.
A flurry of essential firmware and ROM updates followed the March delivery, and it was important to keep up with developments. I was lucky to have just started a sabbatical from my software job and had the time to read through daily discussions on the MEGA65 Discord. I knew other newly minted MEGA65 owners that didn’t have that kind of time and were struggling to dig into their new machines. For them and others, I wrote the MEGA65 Welcome Guide, a supplement to the already excellent documentation that tried to synthesize information about recent changes and practical advice, stuff too temporary for the official manual but still useful to the first 400 owners.
And the new stuff keeps coming. I’ve been keeping track of all of the amazing things this growing community has been doing with the MEGA65 all year, from boxed retail games to music demos to tools and libraries to YouTube videos and tutorials. There was so much being posted, I built the @MEGA65Files Twitter bot as a way for people to be notified of new software and articles posted to the Filehost repository. As of this writing, the Filehost has nearly 200 downloadable files and over 60 articles.
By the end of 2022, there will be 800 MEGA65s in the wild—not counting the 100 Dev Kits—and the pace of development is likely to increase. With more people and more activity, it won’t be sufficient to assume that everyone is reading the Discord chat. I think it’s time for a newsletter.
Whether you already have a MEGA65, have preordered one from a future batch, are jumping in with a Nexys board or the emulator, or are just curious about the MEGA65 project and its community, this Digest will keep you up to date. Firmware updates, shipping status, new software releases, game jams, tips and tricks, and maybe the occasional interview. Things you can do with your MEGA65 right now. It’ll be short, interactive, and free.
There are two things you can do to help:
Look for the first post in mid-September.
Thanks all! GO 65!
From the publisher's feed