Recent posts#
See the blog archives for a more complete list.
2023-11-05 - VCSLib, A C Library for the Atari 2600
The previous blog post, “Your 8-bit System is a Weird PDP-11”, discussed several challenges faced when developing in C, especially for the Atari 2600/VCS.
We’ve overcome those challenges as best we can, and now we can introduce VCSLib, a support library for programming the Atari 2600/VCS with CC65.
Let’s take a tour.
2023-10-28 - Your 8-bit System is a Weird PDP-11
The C programming language is the de facto portable, low-level language. It was written with the PDP-11 minicomputer in mind.
The PDP-11 informed the x86 instruction set, and so in a way, we’re still using them. Today’s computers are so complex that they have to bend over backwards to emulate the simple architecture for which C was designed. It leads some to ask if C is a good fit for modern systems.
Likewise, the PDP-11 doesn’t have a lot in common with 80s arcade games. Game programmers in the 8-bit era wrote code predominantly in assembly language. The C language was around, but mostly in UNIX systems. If anything, they would have been more likely to use a homespun language like Zgrass or even FORTH.
2023-05-16 - Exploring the New 6502 Compiler Based on LLVM
Today, homebrew developers enjoy the convenience of programming the 6502 in C. However, the 6502 is a very different architecture than modern CPUs, and was never designed for C programming.
The 6502 has a small number of 8-bit registers, and limited addressing modes that cannot access the stack efficiently. This makes it difficult to retarget a modern C compiler to the 6502.
In a previous blog post, we explored the process of retargeting a microcontroller C compiler (SDCC) to the 6502. This required development of a brand new code generation backend, which required looking at over 80,000 lines of code. Gabriele Gorla has since improved it to the point where it has been merged into the main SDCC repository.
2023-03-22 - Will ChatGPT replace retro programmers?
An LLM (Large Language Model) is an artificial neural network that statistically models the structure of text. It’s typically trained on a huge corpus of textual data, and tuned for a specific task, like an AI chat assistant (ChatGPT) or a programming helper (Copilot).
I created 8bitworkshop to make it easy for people to explore obsolete technologies. So I wondered: is the latest AI technology going to make the programmers of obsolete technologies obsolete themselves?
tl;dr: Not yet.
2022-12-23 - Atari 800 Winter Solstice Celebration Demo
Every December, I try to make a little wintery demo to exercise one of 8bitworkshop’s platforms. This year, I chose the Atari 800 to test out the new native TypeScript emulator in 8bitworkshop. You can see the demo emulated here.
I revisted my Bally Astrocade “Happy 2020” Demo, which simulates falling snow. It uses pixel-level collision to simulate each falling particle, which creates neat little piles of snow and particles that ripple off the sides of obstacles.
Atari ANTIC Mode $F uses the GTIA chip to add additional modes beyond what the original CTIA chip provides. I used GTIA Mode 10, which is 80 x 192 pixels with nine different colors.
2022-12-01 - Displaying QR codes on 8-bit hardware
It’s often hard to interface the world of 8-bit computing with modern digital devices. These machines don’t have USB, Wifi, Ethernet, or anything resembling a modern interface.
It’s interesting to think about ways older machines can communicate with modern devices using only hardware of the era – even if it might be kind of convoluted. One of these methods might be via QR code.
A QR code is a two-dimensional pattern that encodes a short string of bytes or text – often a URL. These patterns can be printed on paper, or displayed on a screen. If you scan the pattern with your phone’s camera, it decodes the pattern, and displays the encoded text or URL.
2022-11-14 - Mastodon and the Vintage BASIC Bot
Mastodon has gained popularity as an alternative to commercial social media, especially within the #retrocomputing community. Even 8bitworkshop is on Mastodon, so feel free to follow! Just post
@8bitworkshop@oldbytes.space
into your search bar.One feature of the “other” social media network (affectionally known as “Birdsite” on Mastodon) is the presence of bots.
2022-10-03 - 8bitworkshop 3.10.0 Release
It’s been awhile since we had a proper IDE release. Here’s what’s new in 3.10.0:
New Atari PCS Emulator – The old Atari 800 emulator relied upon MAME, which was adequate but lacking in performance and debuggability. The new emulator is written in TypeScript, is cycle-accurate [1] and runs most cartridge-based games pretty well. It can even load certain well-behaved XEX files.
2021-12-21 - 8bitworkshop 3.9.0 Release
The 8bitworkshop IDE build process is finally using a JavaScript bundler (esbuild). This improves modularity and startup time, among other things. It’s a pretty big change, so please let me know if you spot any bugs!
There are a couple of new features:
The Amstrad CPC platform is now available! It emulates a CPC6128 (128K) and includes the cpctelera library for C coding.
2021-08-31 - August 2021 Update
It’s been more than a month since the 8bitworkshop 3.8.0 release, and I’ve been doing lots of prototyping behind the scenes. Some of this work will end up in dead ends, but we might learn a thing or two along the way. So I thought I’d document everything here.
ECMAScript (aka JavaScript) did not have a standardized module system until ES6, which was published in 2015. The ecosystem is still catching up. For example, some browsers still don’t support ES6 modules in web workers, and Node.js only recently added module support. TypeScript has always supported ES6 modules, but good luck getting it to consume old-style IIFE (“immediately-invoked function expression”) modules, or getting it to play nicely with your Node unit tests … etc.
To handle this hodge-podge of module formats, “bundlers” were developed. These tools eat a pile of source code, images, CSS, whatever – and regurgitate it back in whatever format you need. The downside is that they add another level of complexity to your build system. So I’d been avoiding bundlers, and just using the output from the TypeScript compiler directly from the index.html file.
2021-07-16 - 8bitworkshop 3.8.0 Release
The big change in this release is a new Verilog backend. It translates your modules into WebAssembly!
The new backend is based on Verilator 4. It has a modest performance gain (20-50%), 64-bit support, and increased test compliance.
Other changes in the Verilog platform:
2021-06-21 - Emulator Performance: WebAssembly vs. JavaScript
The 8bitworkshop IDE integrates several different kinds of emulators that run in the web browser, each kind with different characteristics. Ideally, our emulators would be:
Performant – They should load quickly, and run at native speeds in modern browsers.
2021-05-18 - 8bitworkshop 3.7.2 Release
A minor update with some bug fixes and some new features.
Added better support for ca65 assembler, though DASM is probably still the better choice for VCS programming. DASM has better parsing of macros (you can step through them in the debugger) and improved error messages.
Improved cycle analysis tool that counts up to 76*4 scanlines and properly inspects JSR subroutines.
2020-10-31 - 3.7.0 Release: BASIC
Click here to program BASIC in the 8bitworkshop IDE now!
Dartmouth professors John G. Kemeny and Thomas E. Kurtz had the idea that every student should have access to a computer. But in those days, batch processing was the law of the land. Programmers would fill out a coding sheet, then a keypunch operator would create a deck of punch cards. The cards were fed into machines, and hours later you might receive results from your program – or if you were unlucky, an error report.
2020-10-14 - Fuzzing the Z-Machine
Playing text adventure games is sort of fun, but takes a lot of brain power. Nowadays we have all this spare CPU capacity going to waste.
What if we let the computer solve the game, and we just sit back and watch? We don’t even need any fancy neural network, we just need good old brute force.
We’re going to throw tons of semi-random input at a text adventure and see what happens. In the security world, this is called fuzzing.
2020-07-19 - 8bitworkshop 3.6.0 Release
The 8bitworkshop IDE 3.6.0 is out, and we’ve added five more awesome platforms, as well as some nifty new debugging features!
Commodore’s VIC-II graphics and SID sound chip were originally destined for a next-gen game console. Engineering convinced CEO Jack Tramiel that a low-cost 64KB computer would be profitable, and thanks to having their own semiconductor fab (acquired from MOS Technology, along with the 6502) they were able to design the chipset in about five months.
2020-07-05 - Retargeting a C Compiler to 6502
I’ve written before about cc65 and some of its optimization challenges. It’s a stable compiler with a robust toolchain, but its code generator doesn’t full advantage of the 6502 when performing 8-bit operations. It places function parameters and many local variables on a separate stack, which requires many calls to helper functions.
I’ve done a survey of 6502 high-level languages, and while many are intriguing, none have the stability and C compatiblity of cc65.
So what’s so hard about the 6502? What’s keeping us from just retargeting a modern C compiler, bringing its powerful optimization routines to 6502? Well, it’s complicated. Like, really complicated.
2020-01-23 - Compiling a C-64 Emulator to WebAssembly
We use a variety of emulators in 8bitworkshop. Many of them, like most of the Z80 emulators, are written from scratch in JavaScript directly against our Platform API. This facilitates deep introspection into the emulator state, which comes in handy for things like debugger support and CPU visualization.
To save effort, we also integrate a couple of open source emulators. Atari 2600 support is courtesy of Javatari, and NES support is courtesy of JSNES. Each of them requires significant patching to expose hooks for the extra features the IDE supports, like breakpoints and bus-monitoring.
We can also use MAME, compiling it to WebAssembly using Emscripten. The trouble is that it’s a bit heavyweight and monolithic, and wants to be treated as an application, not a library. Due to the way it’s architected, interacting with the debugger via JavaScript isn’t really feasible. Even simple things like re-loading the ROM require a ton of Lua scripting.
2019-12-20 - 8bitworkshop 3.5.0 Release
8bitworkshop now supports five additional 8-bit platforms!
2019-09-02 - The Mango One
In 1976, the first 6502-based hobbyist computers were just starting to appear. MOS Technology’s own KIM-1 had a numeric pad and seven-segment display. The competing SYM-1 could draw simple characters on an oscilloscope.
But the real breakthrough would come when the computer could receive input from a full keyboard, and output to a television set. Steve Wozniak demonstrated such a device at Homebrew Computer Club, a 6502-based machine that could drive a 40 column by 24 row character display, and could run Woz’s own Integer BASIC. This device would later be sold as the Apple I.
We’re going to create a similar device in the 8bitworkshop IDE using Verilog.
2019-08-09 - 8bitworkshop 3.4.0 Release
We’ve added yet another platform to the 8bitworkshop IDE, the legendary Nintendo Entertainment System (NES)!
You can program in both C and 6502 assembler, and there are a ton of examples to get you started.
The IDE lets you write C using the cc65 compiler toolchain. While it has lower performance and greater code size than a well-written assembly program, you can still write a pretty good game in C. We use a fork of Shriu’s NESLib library to interface with NES hardware features, and Famitone to play music and sound.
2019-03-17 - Optimizing C array lookups for the 6502
Most of the platforms in the IDE that are powerful enough to support a C compiler are Z80-based. The Z80 isn’t the easiest target for C, but at least it has a lot of registers.
While the 6502 only has three 8-bit registers, the 6502 has strengths the Z80 doesn’t, as we’ll see here.
Let’s compare the two dominant C compilers for these CPUs. We’ll compile a function with the CC65 C compiler for the 6502, and then with the SDCC (Small Device C Compiler) for the Z80. We’ll call the function
getValue()
:2018-12-15 - Designing Hardware with Verilog
Big news! You can use the 8bitworkshop IDE to write Verilog code, and see it executed instantly in real-time on a simulated CRT. Most computers are fast enough to render a game at 60 Hz, which requires simulating Verilog at almost 5 million ticks per second. This is all done in JavaScript!
For example, here’s a simple clock divider module:
The IDE instantly compiles this and starts simulating, showing the output signals on the scope:
2018-11-25 - 3.2.1: batari BASIC; the Sidebar
I came across Fred Quimby’s batari BASIC while developing the first version of 8bitworkshop, and was intrigued. This is a BASIC compiler that targets the 6502, and has specific support for Atari 2600 features. For example, you might define the playfield like this:
You could then set the foreground and background colors:
And animate the playfield, scrolling it downward each frame:
2018-11-19 - New Frontiers in High-Level 6502 Programming
Programming directly in 6502 gets a little fiddly, so a higher-level language can make things easier. There have been many attempts to tame the 6502 to make programming more palatable. Interpreted languages like BASIC, FORTH, and Pascal were popular back in the day, and Infocom games had their own custom VM to run on many platforms. But programmers are a stubborn bunch, and want speed as well as usability.
One approach is to just write a really powerful macro assembler that almost looks like a high-level language. In the 1980s, Lucasfilm developed Macross as “an assembler for people who hate assembly language”. More recently, NESHLA is targeted at NES development, but hasn’t seen much new development since 2005.
It’s been more than 40 years since Chuck Peddle sold the first 6502 samples out of a jar at a trade show. Intrepid developers are still making new languages for the CPU. Here’s a quick survey of some that have been active in the last few years:
2018-10-03 - 3.2.0: Font tools, bankswitching, and cassette loading
New features in 8bitworkshop 3.2.0:
Keyboard Shortcuts for debugging:
Shotrcut
2018-08-26 - 3.1.0: VCS Love, Instant Replay and Playable Links
In 8bitworkshop 3.1.0, we’ve given the VCS platform plenty of love:
Header Files: Header/include files are now viewable and editable via the IDE. But don’t use angle brackets in your includes, because they’ll pull in the old header file versions. Instead, use double quotes, for example:
Bugs Squashed: The emulator was suddenly stopping and displaying a blank screen, requiring a browser refresh. There were also problems when trying to load a ROM of the wrong size. Also, the Program Counter is no longer wonky when single-stepping.
2018-08-06 - Version 3.0.0 Released!
Version 3.0.0 of the 8bitworkshop IDE is out! Under the hood, there are lots of changes:
There’s a new browser storage backend, and your local changes will be migrated over the first time you start the IDE. This means you can save many more projects locally.
The site also now supports HTTPS, but be aware that local changes made on the HTTPS site won’t affect the HTTP site, and vice-versa.
2017-04-27 - Sincere Flattery in the Early Arcade Industry
“If I have seen a little further, it is by standing on the shoulders of giants.” – Isaac Newton
“Imitation is the sincerest form of flattery.” – Charles Caleb Colton
“Art is theft.” – Pablo Picasso